Lesson_17_18_Homework_QQ登录界面

package Lesson_17_18;

import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Font;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class QQ extends JFrame {
	JLabel lb1=null;
	JLabel lb2=null;
	JLabel lb3=null;
	JLabel lb4=null;
	JTextField text=null;
	JPasswordField password=null;
	JButton btnOk=null;
	JCheckBox jc1=null;
	JCheckBox jc2=null;
	
	public QQ(){
		super("QQ登录界面");
		this.setIconImage(new ImageIcon("QQ.jpg").getImage());
		this.setSize(380,230);

		this.setLayout(null);
		this.setResizable(false);
		init();
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	
	public void init(){
		lb1=new JLabel("QQ号:");
		lb2=new JLabel("密码:");
		lb1.setForeground(Color.blue);
		lb2.setForeground(Color.blue);
		lb1.setBounds(20, 20, 80, 30);//空布局中必须使用setBounds方法,才能添加到窗体中
		lb2.setBounds(20, 70, 80, 30);
		this.add(lb1);
		this.add(lb2);
		
		lb3=new JLabel("注册账号");
		lb4=new JLabel("忘记密码");
		lb4.setForeground(Color.cyan);
		lb3.setForeground(Color.cyan);
		lb3.setBounds(290, 25, 80, 20);
		lb4.setBounds(290, 75, 80, 20);
		this.add(lb3);
		this.add(lb4);
		
		text=new JTextField();
		text.setBounds(80, 20, 200, 30);
		this.add(text);
		
		password=new JPasswordField();
		password.setBounds(80, 70, 200, 30);
		this.add(password);
		
		jc1=new JCheckBox("记住密码");
		jc1.setForeground(Color.BLACK);//黑色应该不用设置 默认就是黑色的
		jc1.setBounds(90, 110, 80, 30);
		this.add(jc1);
		
		jc2=new JCheckBox("自动登录");
		jc2.setBounds(180, 110, 80, 30);
		this.add(jc2);
		
		btnOk=new JButton("登录");
		btnOk.setForeground(Color.BLUE);
		btnOk.setBounds(120, 150, 120, 40);
		this.add(btnOk);
		
	}
	
	public static void main(String[] args) {
		new QQ();
	}
}


 

运行结果:

Lesson_17_18_Homework_QQ登录界面_第1张图片

你可能感兴趣的:(Lesson_17_18_Homework_QQ登录界面)