JAVA中打开新页面代码/**
* 打开打印窗口
* url:链接页面或action动作
* Banglu
*/
function printWindow(url){
var sURL = url;
var sFeatures = "toolbar=no, menubar=no, scrollbars=no,resizable=yes, "
"location=no, status=no, titlebar=no, width=800, height=600, top=100, left=100";
window.open(sURL,'notoolbar',sFeatures);
}function exportWindow(url){
var sURL = url;
var sFeatures = "toolbar=no, menubar=no, scrollbars=no,resizable=yes, "
"location=no, status=no, titlebar=no, width=800, height=600, top=50, left=50";
var objwin=window.open(sURL,'export' randomNum(),sFeatures);
objwin.close();
}
/**
* 打开模态窗口
* url:链接页面或action动作
* width:打开模态窗口的宽度
* height:打开模态窗口的高度
* 注意:打开模态窗口的页面中要在head后面加上
* meta http-equiv="Pragma" content="no-cache":禁止模态窗口缓存
* base target="_self"/:模态窗口中的表单在本窗口中提交
* a onClick='window.location = "view-source:"window.location.href'b源文件/b/a 可以查看模态窗口的源文件
* Banglu
*/
function modalWindow(url, width, height){
var sURL = url;
var sFeatures = "dialogWidth:"width"px; dialogHeight:"height"px; "
"help:no; scroll:yes; center:yes; status:no;resizable:yes";
window.showModalDialog(sURL, window, sFeatures);
}/**
* 打开普通窗口
* url:链接页面或action动作
* width:宽度
* height:高度
* Banglu
*/
function openWindow(url, width, height){
var sURL=url;
var sFeatures = "scrollbars=yes, status=yes, resizable=yes,"
"toolbar=yes, menubar=yes, location=yes, titlebar=yes"
if(width!=null){
sFeatures =", width=" width;
}
if(height!=null){
sFeatures =", height=" height;
}
window.open(sURL, 'open' randomNum(), sFeatures);
}/**
* 打开窗口
* url:链接页面或action动作
* width:宽度
* height:高度
Banglu
*/
function openNoBarWindow(url, width, height){
var sURL=url;
var sFeatures = "scrollbars=no, status=no, resizable=no,"
"toolbar=no, menubar=no, location=no, titlebar=no"
if(width!=null){
sFeatures =", width=" width;
sFeatures =", left=" (screen.width-width)/2;
}
if(height!=null){
sFeatures =", height=" height;
sFeatures =", top=" (screen.height-height-100)/2;
}
window.open(sURL, 'openNoBar' randomNum(), sFeatures);
}
/**
* 打开全屏窗口
* url:链接页面或action动作
* Banglu
*/
function openFullWindow(url){
var sURL=url;
var sFeatures = "toolbar=no, menubar=no, scrollbars=no, resizable=yes, "
"location=no, status=no, titlebar=no, width=" (screen.width-10) ", "
"height=" (screen.height-60) ", top=0, left=0";
window.open(sURL, 'full' randomNum(), sFeatures);
}/**
* 打开主窗口
* url:链接页面或action动作
* Banglu
*/
function openMainWindow(url){
var sURL=url;
var sFeatures = "toolbar=no, menubar=no, scrollbars=no, resizable=yes, "
"location=no, status=no,titlebar=no, width=" (screen.width-10) ", "
"height=" (screen.height-60) ", top=0, left=0";
window.open(sURL, 'main', sFeatures);
}
/**
* 设置链接
* url:连接的jsp页面或action动作
* Banglu
*/
function link(url, frameID){
if(frameID==null){
window.location.href = https://www.04ip.com/post/url;
}
else{
window.frames[frameID].location = url
}
}/**
* 回车代替tab
* Banglu
*/
function handleKey(){
var gk = window.event.keyCode;
if (gk==13) {
if(window.event.srcElement.tagName!='TEXTAREA'){
window.event.keyCode=9;
return;
}
}
}/**
* 全屏显示
* Banglu
*/
function fullScreen(){
window.dialogHeight=window.screen.availHeight;
window.dialogWidth=window.screen.availWidth;
}
function Resize_dialog(t,l,w,h) {
window.dialogTop = t "px";
window.dialogLeft = l "px";
window.dialogHeight = h "px";
window.dialogWidth = w "px";
}
运行时可调用浏览器打开一个网页 , 网页地址在代码中的java代码怎么写?网页地址在代码中页面java代码的java代码写法如下页面java代码:
packagecom.test;
importjava.lang.reflect.Method;
//实现打开浏览器并跳到指定网址的类
publicclassBareBonesBrowserLaunch{
publicstaticvoidopenURL(Stringurl){
try{
browse(url);
}catch(Exceptione){
}
}
privatestaticvoidbrowse(Stringurl)throwsException{
//获取操作系统的名字
StringosName=System.getProperty("os.name","");
if(osName.startsWith("MacOS")){
//苹果的打开方式
ClassfileMgr=Class.forName("com.apple.eio.FileManager");
MethodopenURL=fileMgr.getDeclaredMethod("openURL",newClass[]{String.class});
openURL.invoke(null,newObject[]{url});
}elseif(osName.startsWith("Windows")){
//windows的打开方式 。
Runtime.getRuntime().exec("rundll32url.dll,FileProtocolHandler" url);
}else{
//UnixorLinux的打开方式
String[]browsers={"firefox","opera","konqueror","epiphany","mozilla","netscape"};
Stringbrowser=null;
for(intcount=0;countbrowsers.lengthbrowser==null;count)
//执行代码页面java代码,在brower有值后跳出页面java代码,
//这里是如果进程创建成功了,==0是表示正常结束 。
if(Runtime.getRuntime().exec(newString[]{"which",browsers[count]}).waitFor()==0)
browser=browsers[count];
if(browser==null)
thrownewException("Couldnotfindwebbrowser");
else
//这个值在上面已经成功的得到了一个进程 。
Runtime.getRuntime().exec(newString[]{browser,url});
}
}
}
//主方法测试类
publicstaticvoidmain(String[]args){
Stringurl="";
BareBonesBrowserLaunch.openURL(url);
}
登陆界面的java代码怎么写?import java.awt.*; \x0d\x0aimport javax.swing.*; \x0d\x0aimport java.awt.event.*; \x0d\x0aimport java.sql.*; \x0d\x0a\x0d\x0aclass LoginFrm extends JFrame implements ActionListener \x0d\x0a{ \x0d\x0aJLabel lbl1=new JLabel("用户名"); \x0d\x0aJLabel lbl2=new JLabel("密码"); \x0d\x0aJTextField txt=new JTextField(15); \x0d\x0aJPasswordField pf=new JPasswordField(); \x0d\x0aJButton btn1=new JButton("确定"); \x0d\x0aJButton btn2=new JButton("取消"); \x0d\x0a\x0d\x0apublic LoginFrm() \x0d\x0a{ \x0d\x0athis.setTitle("登陆"); \x0d\x0aJPanel jp=(JPanel)this.getContentPane(); \x0d\x0ajp.setLayout(new GridLayout(3,2,10,10)); \x0d\x0ajp.add(lbl1);jp.add(txt); \x0d\x0ajp.add(lbl2);jp.add(pf); \x0d\x0ajp.add(btn1);jp.add(btn2); \x0d\x0abtn1.addActionListener(this); \x0d\x0abtn2.addActionListener(this); \x0d\x0a} \x0d\x0a\x0d\x0apublic void actionPerformed(ActionEvent ae) \x0d\x0a{ \x0d\x0aif(ae.getSource()==btn1) \x0d\x0a{ \x0d\x0atry \x0d\x0a{ \x0d\x0aClass.forName("sun.jdbc.odbc.JdbcOdbcDriver"); \x0d\x0aConnection con=DriverManager.getConnection("jdbc:odbc:MyDB","",""); \x0d\x0aStatement cmd=con.createStatement(); \x0d\x0aResultSet rs=cmd.executeQuery("select * from loginAndpassword where login='" txt.getText() "' and password='" pf.getText() "'"); \x0d\x0aif(rs.next()) \x0d\x0a{ \x0d\x0aJOptionPane.showMessageDialog(null,"登陆成功页面java代码!"); \x0d\x0a} \x0d\x0aelse \x0d\x0aJOptionPane.showMessageDialog(null,"用户名或密码错误页面java代码!"); \x0d\x0a} catch(Exception ex){} \x0d\x0a\x0d\x0aif(ae.getSource()==btn2) \x0d\x0a{ \x0d\x0atxt.setText(""); \x0d\x0apf.setText(""); \x0d\x0a} \x0d\x0a} \x0d\x0a} \x0d\x0a\x0d\x0apublic static void main(String arg[]) \x0d\x0a{ \x0d\x0aJFrame.setDefaultLookAndFeelDecorated(true); \x0d\x0aLoginFrm frm=new LoginFrm(); \x0d\x0afrm.setSize(400,200); \x0d\x0afrm.setVisible(true); \x0d\x0a} \x0d\x0a}
如何在HTML页面中写java代码Java要运行html代码,需要运行在服务器端,也就是servlet容器中,经过容器编译解析,返回html静态内容,示例如下:
在servlet里面写就可以了
引入一系列包
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
public class Servlet1 extends HttpServlet {
public void doGet(ServletRequest req,ServletResponse res)throws ServletException, IOException{try{PrintWriter pw=res.getWriter();//在浏览器输出需要
pw.println("scriptscript");}catch(exception e){="" e.printstacktrace();="" 为发现调试错误}}}=""
【页面java代码 java界面代码大全】页面java代码的介绍就聊到这里吧,感谢你花时间阅读本站内容 , 更多关于java界面代码大全、页面java代码的信息别忘了在本站进行查找喔 。
推荐阅读
- 头条如何做菜单推广,头条如何推广产品
- 体育区篮球游戏故事墙,幼儿园篮球故事情节的教案
- kadiya直播录屏,直播录屏怎么打开
- java添加代码 java怎么添加
- 占星单机游戏下载,给大家介绍几个占星软件
- 怎么关注邳州教育公众号,怎么关注邳州教育公众号呢
- linux评估机器的命令 linux常用命令 ping
- 手机怎么检测移动硬盘,手机怎么检测移动硬盘有没有坏道
- 手机恋爱养成游戏r18,手机恋爱养成单机