package denglu;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
public class Dl extends JFrame{
private static final long serialVersionUID = 1L;
Font f1=new Font("宋体", Font.PLAIN, 14);
JLabel lb1,lb2,lb3,lb4;
JButton b1,b2,b3;
JComboBox cb;
JTextField tf;
JTextField pw;
public void CreateJFrame(String title) {
JFrame jf = new JFrame(title);
Container container = jf.getContentPane();
lb1=new JLabel(new ImageIcon("image/tou.gif"));
lb2=new JLabel(new ImageIcon("image/qqtou.gif"));
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String args[]) { // 在主方法中调用createJFrame()方法
new Dl().CreateJFrame("QQ登陆界面");
}
}
jp=new JPanel();
jp.setLayout(null);
jp_jlb1=new JLabel(new ImageIcon("image/qqtou.gif"));
jp_jlb1.setBounds(18, 10, 85, 85); //设置标签位置 前提是要空布局
jp_jtf=new JTextField("QQ号码/手机/邮箱");
jp_jtf.setForeground(Color.LIGHT_GRAY);//设置颜色
jp_jtf.addMouseListener(this);
jp_jtf.setBounds(118, 11, 170, 25);
jp_pw=new TextField("密码",24);
jp_pw.setForeground(Color.LIGHT_GRAY);
jp_pw.addMouseListener(this);
jp_pw.setBounds(118, 45, 170, 24);
jp_jlb3=new JLabel("注册账号");
jp_jlb3.setFont(f1);
jp_jlb3.setForeground(Color.BLUE);
jp_jlb3.setBounds(300, 10, 70, 25);
jp_jlb4=new JLabel("找回密码");
jp_jlb4.setFont(f1);//设置"找回密码"字体
jp_jlb4.setForeground(Color.BLUE); //设置"找回密码"字体颜色
jp_jlb4.setBounds(300, 43, 70, 25);
String[] s={"在线","隐身","忙碌","离线"}; //设置状态
cb=new JComboBox(s);
cb.setFont(f1);
cb.setBounds(300, 78, 60, 21);
jp_jcb1=new JCheckBox("记住密码");
jp_jcb1.setFont(f1);
jp_jcb1.setBounds(114, 78, 90, 20);
jp_jcb2=new JCheckBox("自动登录");
jp_jcb2.setFont(f1);
jp_jcb2.setBounds(206, 78, 90, 20);
jp_jb1=new JButton("多账号");
jp_jb1.setFont(f1);
jp_jb1.setBounds(10, 120, 76, 21);
jp_jb2=new JButton("设置");
jp_jb2.setFont(f1);
jp_jb2.setBounds(95, 120, 65, 21);
jp_jb3=new JButton("登录");
jp_jb3.setFont(f1);
jp_jb3.setBounds(297, 120, 65, 21);
//添加各个组件
jp.add(jp_jlb1);
jp.add(jp_jtf);
jp.add(jp_jlb4);
jp.add(jp_pw);
jp.add(jp_jlb3);
jp.add(cb);
jp.add(jp_jcb1);
jp.add(jp_jcb2);
jp.add(jp_jb1);
jp.add(jp_jb2);
jp.add(jp_jb3);
this.add(jlb,"North");//标签放到最北部
this.add(jp,BorderLayout.CENTER);// 放到中部
this.setIconImage(new ImageIcon("image/qq.gif").getImage());//设置窗口上的qq小图片
this.setResizable(false);//不允许放大,改变窗口大小等
this.setSize(380,275);
this.setLocation(500,200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}