import java.awt.*;
import javax.swing.*;
public class LoadIn extends JFrame{
JButton queren,quxiao; //定义变量
JTextField txt;
JPasswordField Password;
JLabel yonghuming,mima;
JPanel p1,p2,p3;
public static void main(String[] args) {
// TODO Auto-generated method stub
LoadIn test6=new LoadIn();
}
public Liuzhi()
{ 重点内容
queren=new JButton(“确认”); //创建组件
quxiao=new JButton(“取消”);
txt=new JTextField(10);
Password=new JPasswordField(10);
yonghuming=new JLabel(“用户名:”);
mima=new JLabel(“密 码:”);
p1=new JPanel();
p2=new JPanel();
p3=new JPanel();
this.setLayout(new GridLayout(3,1,5,5)); //设置布局管理器
p1.add(yonghuming); //添加组件
p1.add(txt);
p2.add(mima);
p2.add(Password);
p3.add(queren);
p3.add(quxiao);
this.add(p1);
this.add(p2);
this.add(p3);
Font font=new Font(“宋体”,Font.PLAIN,13);//设置窗体属性
this.setTitle(“登录界面”);
setResizable(false); //设置是否可见
this.setSize(280, 150);
this.setVisible(true);
}
}
运行结果如下图所示