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

Java语言编写简单的QQ登录界面 续(1)

2015-07-16 10:26 573 查看
import java.awt.BorderLayout;
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 QQ1 {
public static void main(String[] args) {
JFrame frame=new JFrame("登陆界面");

JPanel jp=new JPanel(new BorderLayout());
jp.add(createTopPanel(),BorderLayout.NORTH);
jp.add(createCenterPanel(),BorderLayout.CENTER);
jp.add(createBottomPanel(),BorderLayout.SOUTH);

frame.setContentPane(jp);
frame.setBounds(600,300,300,200);
frame.setResizable(false);          //窗口大小不可变
frame.setVisible(true);
}

public static JPanel createTopPanel(){
JPanel jp1=new JPanel();
JLabel jlb1=new JLabel("欢迎登录");
jp1.add(jlb1);
return jp1;
}
public static JPanel createCenterPanel(){
JPanel jp2=new JPanel();
jp2.setLayout(new BorderLayout());

jp2.add(createUserPwdPanel(),BorderLayout.NORTH);

return jp2;
}
public static JPanel createUserPwdPanel(){
JPanel jp21=new JPanel();
jp21.setLayout(new GridLayout(2,1,3,4));
jp21.add(crateUnPanel());
jp21.add(cratePwPanel());
return jp21;
}
public static JPanel crateUnPanel(){
JPanel jp211=new JPanel();
jp211.setLayout(new BorderLayout());

JLabel jlb211=new JLabel("     用 户 名            ");
JTextField jtf211=new JTextField();
jp211.add(jlb211,BorderLayout.WEST);
jp211.add(jtf211,BorderLayout.CENTER );
return jp211;
}
public static JPanel cratePwPanel(){
JPanel jp212=new JPanel();
jp212.setLayout(new BorderLayout());

JLabel jlb212=new JLabel("     密     码             ");
JPasswordField jtf212=new JPasswordField();
jp212.add(jlb212,BorderLayout.WEST);
jp212.add(jtf212,BorderLayout.CENTER);
return jp212;
}
public static JPanel createBottomPanel(){
JPanel jp3=new JPanel();
JButton jb1=new JButton("登录");
JButton jb2=new JButton("注册");
JButton jb3=new JButton("取消");

jp3.add(jb1);
jp3.add(jb2);
jp3.add(jb3);
return jp3;
}
}
<img src="http://img.blog.csdn.net/20150716102637768" alt="" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: