java页面代码,java界面代码大全

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 = 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代码怎么写?

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.sql.*;

class LoginFrm extends JFrame implements ActionListener

{

JLabel lbl1=new JLabel("用户名");

JLabel lbl2=new JLabel("密码");

JTextField txt=new JTextField(15);

JPasswordField pf=new JPasswordField();

JButton btn1=new JButton("确定");

JButton btn2=new JButton("取消");

public LoginFrm()

{

this.setTitle("登陆");

JPanel jp=(JPanel)this.getContentPane();

jp.setLayout(new GridLayout(3,2,10,10));

jp.add(lbl1);jp.add(txt);

jp.add(lbl2);jp.add(pf);

jp.add(btn1);jp.add(btn2);

btn1.addActionListener(this);

btn2.addActionListener(this);

}

public void actionPerformed(ActionEvent ae)

{

if(ae.getSource()==btn1)

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con=DriverManager.getConnection("jdbc:odbc:MyDB","","");

Statement cmd=con.createStatement();

ResultSet rs=cmd.executeQuery("select * from loginAndpassword where login='"+txt.getText()+"' and password='"+pf.getText()+"'");

if(rs.next())

{

JOptionPane.showMessageDialog(null,"登陆成功!");

}

else

JOptionPane.showMessageDialog(null,"用户名或密码错误!");

} catch(Exception ex){}

if(ae.getSource()==btn2)

{

txt.setText("");

pf.setText("");

}

}

}

public static void main(String arg[])

{

JFrame.setDefaultLookAndFeelDecorated(true);

LoginFrm frm=new LoginFrm();

frm.setSize(400,200);

frm.setVisible(true);

}

}

用java写一个登陆界面代码。

概述

具体框架使用jframe,文本框组件:JTextField;密码框组件:JPasswordField;标签组件:JLabel;复选框组件:JCheckBox;单选框组件:JRadioButton;按钮组件JButton。

登录界面:

代码实例

import javax.swing.*;

import java.awt.*;   //导入必要的包

public class denglu extends JFrame{

JTextField jTextField ;//定义文本框组件

JPasswordField jPasswordField;//定义密码框组件

JLabel jLabel1,jLabel2;

JPanel jp1,jp2,jp3;

JButton jb1,jb2; //创建按钮

public denglu(){

jTextField = new JTextField(12);

jPasswordField = new JPasswordField(13);

jLabel1 = new JLabel("用户名");

jLabel2 = new JLabel("密码");

jb1 = new JButton("确认");

jb2 = new JButton("取消");

jp1 = new JPanel();

jp2 = new JPanel();

jp3 = new JPanel();

//设置布局

this.setLayout(new GridLayout(3,1));

jp1.add(jLabel1);

jp1.add(jTextField);//第一块面板添加用户名和文本框

jp2.add(jLabel2);

jp2.add(jPasswordField);//第二块面板添加密码和密码输入框

jp3.add(jb1);

jp3.add(jb2); //第三块面板添加确认和取消

//        jp3.setLayout(new FlowLayout());  //因为JPanel默认布局方式为FlowLayout,所以可以注销这段代码.

this.add(jp1);

this.add(jp2);

this.add(jp3);  //将三块面板添加到登陆框上面

//设置显示

this.setSize(300, 200);

//this.pack();

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

this.setTitle("登陆");

}

public static void main(String[] args){

new denglu();

}

}

拓展内容

java swing包

Swing 是一个为Java设计的GUI工具包。

Swing是JAVA基础类的一部分。

Swing包括了图形用户界面(GUI)器件如:文本框,按钮,分隔窗格和表。

Swing提供许多比AWT更好的屏幕显示元素。它们用纯Java写成,所以同Java本身一样可以跨平台运行,这一点不像AWT。它们是JFC的一部分。它们支持可更换的面板和主题(各种操作系统默认的特有主题),然而不是真的使用原生平台提供的设备,而是仅仅在表面上模仿它们。这意味着你可以在任意平台上使用JAVA支持的任意面板。轻量级组件的缺点则是执行速度较慢,优点就是可以在所有平台上采用统一的行为。

概念解析:

JFrame – java的GUI程序的基本思路是以JFrame为基础,它是屏幕上window的对象,能够最大化、最小化、关闭。

JPanel – Java图形用户界面(GUI)工具包swing中的面板容器类,包含在javax.swing 包中,可以进行嵌套,功能是对窗体中具有相同逻辑功能的组件进行组合,是一种轻量级容器,可以加入到JFrame窗体中。。

JLabel – JLabel 对象可以显示文本、图像或同时显示二者。可以通过设置垂直和水平对齐方式,指定标签显示区中标签内容在何处对齐。默认情况下,标签在其显示区内垂直居中对齐。默认情况下,只显示文本的标签是开始边对齐;而只显示图像的标签则水平居中对齐。

JTextField –一个轻量级组件,它允许编辑单行文本。

JPasswordField – 允许我们输入了一行字像输入框,但隐藏星号(*) 或点创建密码(密码)

JButton – JButton 类的实例。用于创建按钮类似实例中的 "Login"。


当前文章:java页面代码,java界面代码大全
当前地址:http://scyanting.com/article/phcecd.html