package test;
import java.awt.*;
import javax.swing.*;
public class demo extends JFrame{
private JButton jb1, jb2;
private JPanel jp1, jp2, jp3;
private JLabel jl1, jl2;
private JTextField jtf1, jtf2;
//private JPasswordField jtf2;
public static void main(String[] args){
demo demo1 = new demo();
}
//构造函数
public demo(){
jb1 = new JButton("登录");
jb2 = new JButton("取消");
jp1 = new JPanel(new FlowLayout());
jp2 = new JPanel(new FlowLayout());
jp3 = new JPanel(new FlowLayout());
jl1 = new JLabel("用户名");
jl2 = new JLabel("密 码");
jtf1 = new JTextField(10);
jtf2 = new JPasswordField(10);
jp1.add(jl1);
jp1.add(jtf1);
jp2.add(jl2);
jp2.add(jtf2);
jp3.add(jb1);
jp3.add(jb2);
this.setLayout(new GridLayout(3, 1));
this.add(jp1);
this.add(jp2);
this.add(jp3);
this.setTitle("你好啊!");
this.setSize(260, 150);
this.setLocation(300, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.setVisible(true);
}
}
java之用户登录界面
最新推荐文章于 2024-05-16 08:59:34 发布