您的位置:首页 > 编程语言 > Java开发

java窗口登陆

2014-11-25 17:13 204 查看
import javax.swing.*;
import java.awt.*;
import java.util.Random;
public class Windows {

/**
* @param args
*/
public static void main(String[] args) {
// TODO 自动生成的方法存根
Random ra=new Random();
int num=ra.nextInt(1000)+1000;
JFrame window1=new JFrame("用户登录");
Container con=window1.getContentPane();
con.setBackground(Color.red);
window1.setBounds(60,100,400,300);
window1.setLayout(null);
JLabel l1=new JLabel("用户名");
JLabel l2=new JLabel("密码");
JLabel l3=new JLabel("验证码");
JLabel l4=new JLabel(Integer.toString(num));
JPasswordField j=new JPasswordField(10);
JTextField j1=new JTextField(10);
JTextField j2=new JTextField(10);
JButton b1=new JButton("确定");
JButton b2=new JButton("重置");
JButton b3=new JButton("取消");
window1.setVisible(true);
window1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window1.add(l1);
l1.setBounds(30,30,50,50);
window1.add(j1);
j1.setBounds(100,46,100,20);
window1.add(l2);
l2.setBounds(30,60,100,100);
window1.add(j);
j.setBounds(100,96,100,20);
window1.add(l3);
l3.setBounds(30,140,50,50);
window1.add(j2);
j2.setBounds(100,148,100,20);
window1.add(l4);
l4.setBounds(222,119,100,100);
window1.add(b1);
b1.setBounds(30,200,100,30);
window1.add(b2);
b2.setBounds(130,200,100,30);
window1.add(b3);
b3.setBounds(230,200,100,30);

}

}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐