/**
* 2018.8.14
* 作者:小孟鱼
* 功能:登陆界面
* 1.文本框(JTextField)
* 2.密码框(JPasswordField)
* 3.标签(JLabel)
*/
package com.gui;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Test_gui_6 extends JFrame{
//定义组件
JPanel jp1,jp2,jp3;
JLabel jlb1,jlb2;//标签
JButton jb1,jb2;
JTextField jtf1;
JPasswordField jpf1;
public static void main(String[] args) {
Test_gui_6 test_gui_6=new Test_gui_6();
}
//构造函数
public Test_gui_6() {
jp1=new JPanel();
jp2=new JPanel();
jp3=new JPanel();
jlb1=new JLabel("用户名");
jlb2=new JLabel("密 码");
jb1=new JButton("登录");
jb2=new JButton("取消");
jtf1=new JTextField(10);//10代表宽度
jpf1=new JPasswordField (10);
//设置布局管理
this.setLayout(new GridLayout(3,1));
//加入各个组件
jp1.add(jlb1);
jp1.add(jtf1);
jp2.add(jlb2);
jp2.add(jpf1);
jp3.add(jb1);
jp3.add(jb2);
//加入到JFrame
this.add(jp1);
this.add(jp2);
this.add(jp3);
//给窗口设置一个标题
this.setTitle("会员管理系统");
//给窗口设置一个大小
this.setSize(300, 300);
//禁止用户改变窗口的大小
this.setResizable(false);
//设置窗口的初始位置
this.setLocationRelativeTo(null);
//this.setLocation(300, 300);
//设置当关闭窗口时,保证JVM也关闭
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//显示
this.setVisible(true);
}
}