Swing界面

package cn318;

import javax.swing.*;
import java.awt.*;

public class Interface_1 extends JFrame {

	/**
	 * qq界面
	 */

	private JButton buEnter, buExit, buRegister, buClear;
	private JLabel label1, label2, label3, label4, label5;
	private JTextField jt1;
	private JPasswordField jpf;
	private JCheckBox jc1, jc2;
	private JPanel jp1, jp2, jp3, jp4;
	private JTabbedPane jtp;// 选项卡窗格

	public static void main(String[] args) {
		Interface_1 interface1 = new Interface_1();

	}

	public Interface_1() {
		// 按钮初始化
		buEnter = new JButton("登录");
		buExit = new JButton("取消");
		buRegister = new JButton("注册账号");
		buClear = new JButton("清除帐号");

		// 标签初始化
		label1 = new JLabel(new ImageIcon("image/qq1.jpg"));
		label2 = new JLabel("  账       号", JLabel.LEFT);
		label3 = new JLabel("  密       码", JLabel.LEADING);
		label4 = new JLabel("忘记密码", JLabel.CENTER);
		label5 = new JLabel("账号升级", JLabel.CENTER);
                                //设置颜色字体
		label4.setFont(new Font("宋体", Font.BOLD, 14));
		label4.setForeground(Color.red);
		label5.setFont(new Font("隶书", Font.BOLD, 16));
		// 设置当鼠标移动到此处时箭头变为手型
		label5.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

		// 单行文本框初始化
		jt1 = new JTextField(15);
		// 密码框初始化
		jpf = new JPasswordField(15);
		// 复选框初始化
		jc1 = new JCheckBox("记住密码");
		jc2 = new JCheckBox("自动登录");

		// 面板初始化
		jp1 = new JPanel();
		jp2 = new JPanel();
		jp3 = new JPanel();
		jp4 = new JPanel();
		// 选项卡窗格初始化
		jtp = new JTabbedPane();

		// 设置各个面板
                            
		jp1.setLayout(new GridLayout(3, 3));//面板1使用网格布局管理器
		jp1.add(label2);
		jp1.add(jt1);
		jp1.add(buClear);
		jp1.add(label3);
		jp1.add(jpf);
		jp1.add(label4);
		jp1.add(jc1);
		jp1.add(jc2);
		jp1.add(label5);

		jp2.setBackground(Color.BLUE);
		jp3.setBackground(Color.GREEN);

		jp4.add(buEnter);
		jp4.add(buExit);
		jp4.add(buRegister);

		jtp.add("QQ 号码", jp1);
		jtp.add("手机号码", jp2);
		jtp.add("电子邮箱", jp3);

		// 设置布局管理器
		this.add(label1, BorderLayout.NORTH);
		this.add(jtp, BorderLayout.CENTER);
		this.add(jp4, BorderLayout.SOUTH);

		// 设置基本属性
		this.setTitle("My QQ登录界面");
		this.setSize(300, 260);
		this.setLocationRelativeTo(null);
		this.setIconImage(new ImageIcon("image/qq.png").getImage());
		this.setAlwaysOnTop(true);
		this.setResizable(false);
		this.setDefaultCloseOperation(3);
		this.setVisible(true);

	}

}
画面所得简陋写。。。。。

 

你可能感兴趣的:(swing,qq)