⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 register.java

📁 JAVA做的QQ软件,感兴趣的可以看看,收藏依旧
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JRadioButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import java.awt.event.*;
import java.io.*;
import java.net.*;

//  定义用户注册类Register,生成用户注册界面

public class Register extends JFrame {

	private JPanel jContentPane = null;
	private JPanel user_infoPanel = null;
	private JPanel pw_safetyPanel = null;
	private JButton cmp_registerButton = null;
	private JLabel welcomeLabel = null;
	private JLabel noticeLabel = null;
	private JLabel tagLabel = null;
	private JLabel tagLabel1 = null;
	private JLabel tagLabel2 = null;
	private JLabel tagLabel3 = null;
	private JLabel user_nameLabel = null;
	private JLabel passwordLabel = null;
	private JLabel passwordLabel1 = null;
	private JTextField user_nameTextField = null;
	private JPasswordField jPasswordField = null;
	private JPasswordField jPasswordField1 = null;
	private JButton checkButton = null;
	private JLabel checkLabel = null;
	private JTextArea jTextArea = null;
	private JLabel nameLabel = null;
	private JLabel sexLabel = null;
	private JLabel jLabel = null;
	private JRadioButton sex_maleRadioButton = null;
	private JRadioButton sex_femaleRadioButton = null;
	private JTextField nameTextField = null;
	private JTextField ageTextField = null;
	private JLabel cityLabel = null;
	private JTextField cityTextField = null;
	private JLabel telLabel = null;
	private JTextField telTextField = null;
	private JTextField signatureTextField = null;
	private JLabel signatureLabel = null;
	private JCheckBox pw_safetyCheckBox = null;
	private JLabel questionLabel = null;
	private JLabel answerLabel = null;
	private JTextField answerTextField = null;
	private JTextArea noticTextArea = null;
	private JLabel noticeLabel1 = null;
	private JLabel tagLabel4 = null;
	private JLabel tagLabel5 = null;
	private JComboBox questionsComboBox = null;
	
	private static String inSex = Sex.MALE;  //  用来存储用户性别
	private JComboBox getQuestionsComboBox() {

		if (questionsComboBox == null) {
			questionsComboBox = new JComboBox();
			questionsComboBox.setEditable(true);
			questionsComboBox.setEnabled(false);
			questionsComboBox.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
			questionsComboBox.setForeground(java.awt.Color.magenta);
			questionsComboBox.setSize(new java.awt.Dimension(208,25));
			questionsComboBox.setLocation(new java.awt.Point(180,60));
			questionsComboBox.setMaximumRowCount(4);
			questionsComboBox.addItem("我是谁?");
			questionsComboBox.addItem("我是男还是女?");
			questionsComboBox.addItem("我最爱的人是谁?");
			questionsComboBox.addItem("我最爱的颜色?");
			questionsComboBox.addItem("我最爱的电影?");
			questionsComboBox.addItem("我最爱的食物?");
			questionsComboBox.setToolTipText("请输入您的问题或从列表中选择");
			questionsComboBox.setSelectedIndex(-1);
			questionsComboBox.setBackground(new java.awt.Color(255,255,204));
		}
		return questionsComboBox;
	}

	//  定义主函数main()
	
	public static void main(String []args)
	{
		new Register();
	}

	//  定义构造函数
	
	public Register() {
		super();
		initialize();
	}

	//  定义初始化函数initialize()
	
	private void initialize() {
		
		this.setSize(587, 634);
		this.setName("frame");		
		this.setBackground(new java.awt.Color(232,228,216));
		this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		this.setResizable(false);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/pictures/logo1.jpg")));
		this.setContentPane(getJContentPane());
		this.setTitle("Fetion用户注册");
		this.setLocationRelativeTo(null);
		this.setVisible(true);	
	
	}	

	private JPanel getJContentPane() {
		if (jContentPane == null) {
			welcomeLabel = new JLabel();
			welcomeLabel.setBounds(new java.awt.Rectangle(21,6,540,51));
			welcomeLabel.setIcon(new ImageIcon(getClass().getResource("/pictures/welcome.jpg")));
			welcomeLabel.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 18));
			welcomeLabel.setForeground(java.awt.Color.gray);
			welcomeLabel.setText("请输入注册信息……");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.setName("");
			jContentPane.setBackground(new java.awt.Color(188,222,255));
			jContentPane.add(getUser_infoPanel(), null);
			jContentPane.add(getPw_safetyPanel(), null);
			jContentPane.add(getCmp_registerButton(), null);
			jContentPane.add(welcomeLabel, null);
		}
		return jContentPane;
	}

	private JPanel getUser_infoPanel() {
		if (user_infoPanel == null) {
			signatureLabel = new JLabel();
			signatureLabel.setFont(new java.awt.Font("黑体", java.awt.Font.BOLD, 14));
			signatureLabel.setForeground(new java.awt.Color(102,0,102));
			signatureLabel.setSize(new java.awt.Dimension(78,22));
			signatureLabel.setLocation(new java.awt.Point(34,275));
			signatureLabel.setText("个性签名:");
			telLabel = new JLabel();
			telLabel.setText("联系电话:");
			telLabel.setSize(new java.awt.Dimension(80,16));
			telLabel.setFont(new java.awt.Font("黑体", java.awt.Font.BOLD, 14));
			telLabel.setForeground(new java.awt.Color(102,0,102));
			telLabel.setLocation(new java.awt.Point(324,200));
			cityLabel = new JLabel();
			cityLabel.setForeground(new Color(102, 0, 102));
			cityLabel.setText("所在城市:");
			cityLabel.setSize(new java.awt.Dimension(77,16));
			cityLabel.setLocation(new java.awt.Point(324,170));
			cityLabel.setFont(new Font("\u9ed1\u4f53", Font.BOLD, 14));
			jLabel = new JLabel();
			jLabel.setForeground(new Color(102, 0, 102));
			jLabel.setText("年  龄:");
			jLabel.setSize(new java.awt.Dimension(66,16));
			jLabel.setLocation(new java.awt.Point(34,231));
			jLabel.setFont(new Font("\u9ed1\u4f53", Font.BOLD, 14));
			sexLabel = new JLabel();
			sexLabel.setForeground(new Color(102, 0, 102));
			sexLabel.setText("性  别:");
			sexLabel.setSize(new java.awt.Dimension(67,16));
			sexLabel.setLocation(new java.awt.Point(34,200));
			sexLabel.setFont(new Font("\u9ed1\u4f53", Font.BOLD, 14));
			nameLabel = new JLabel();
			nameLabel.setForeground(new Color(102, 0, 102));
			nameLabel.setText("真实姓名:");
			nameLabel.setSize(new java.awt.Dimension(82,16));
			nameLabel.setLocation(new java.awt.Point(34,172));
			nameLabel.setFont(new Font("\u9ed1\u4f53", Font.BOLD, 14));
			checkLabel = new JLabel();
			checkLabel.setText("检测用户名");
			checkLabel.setSize(new java.awt.Dimension(80,27));
			checkLabel.setForeground(java.awt.Color.red);
			checkLabel.setLocation(new java.awt.Point(357,62));
			passwordLabel1 = new JLabel();
			passwordLabel1.setForeground(new Color(102, 0, 102));
			passwordLabel1.setText("重复密码:");
			passwordLabel1.setLocation(new java.awt.Point(34,123));
			passwordLabel1.setSize(new java.awt.Dimension(83,20));
			passwordLabel1.setFont(new Font("\u9ed1\u4f53", Font.BOLD, 14));
			passwordLabel = new JLabel();
			passwordLabel.setForeground(new Color(102, 0, 102));
			passwordLabel.setText("密  码:");
			passwordLabel.setLocation(new java.awt.Point(35,93));
			passwordLabel.setSize(new java.awt.Dimension(64,20));
			passwordLabel.setFont(new Font("\u9ed1\u4f53", Font.BOLD, 14));
			user_nameLabel = new JLabel();
			user_nameLabel.setForeground(new java.awt.Color(102,0,51));
			user_nameLabel.setText("用户名:");
			user_nameLabel.setLocation(new java.awt.Point(35,63));
			user_nameLabel.setSize(new java.awt.Dimension(65,20));
			user_nameLabel.setFont(new java.awt.Font("黑体", java.awt.Font.BOLD, 14));
			tagLabel3 = new JLabel();
			tagLabel3.setForeground(java.awt.Color.magenta);
			tagLabel3.setText("*");
			tagLabel3.setLocation(new java.awt.Point(15,127));
			tagLabel3.setSize(new java.awt.Dimension(16,20));
			tagLabel3.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 24));
			tagLabel2 = new JLabel();
			tagLabel2.setForeground(java.awt.Color.magenta);
			tagLabel2.setText("*");
			tagLabel2.setSize(new java.awt.Dimension(16,20));
			tagLabel2.setLocation(new java.awt.Point(14,97));
			tagLabel2.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 24));
			tagLabel1 = new JLabel();
			tagLabel1.setForeground(java.awt.Color.magenta);
			tagLabel1.setText("*");
			tagLabel1.setLocation(new java.awt.Point(15,67));
			tagLabel1.setSize(new java.awt.Dimension(16,20));
			tagLabel1.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 24));
			tagLabel = new JLabel();
			tagLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 24));
			tagLabel.setForeground(java.awt.Color.magenta);
			tagLabel.setLocation(new java.awt.Point(385,17));
			tagLabel.setSize(new java.awt.Dimension(16,20));
			tagLabel.setText("*");
			noticeLabel = new JLabel();
			noticeLabel.setBounds(new java.awt.Rectangle(309,8,215,30));
			noticeLabel.setFont(new java.awt.Font("仿宋_GB2312", java.awt.Font.BOLD, 14));
			noticeLabel.setForeground(java.awt.Color.black);
			noticeLabel.setText("注意:带有  的项为必填信息!");
			user_infoPanel = new JPanel();
			user_infoPanel.setLayout(null);
			user_infoPanel.setBounds(new java.awt.Rectangle(20,64,542,322));
			user_infoPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
			user_infoPanel.setForeground(java.awt.Color.gray);
			user_infoPanel.setFont(new java.awt.Font("黑体", java.awt.Font.PLAIN, 12));
			user_infoPanel.setBackground(new java.awt.Color(236,236,244));
			user_infoPanel.add(noticeLabel, null);
			user_infoPanel.add(tagLabel, null);
			user_infoPanel.add(tagLabel1, null);
			user_infoPanel.add(tagLabel2, null);
			user_infoPanel.add(tagLabel3, null);
			user_infoPanel.add(user_nameLabel, null);
			user_infoPanel.add(passwordLabel, null);
			user_infoPanel.add(passwordLabel1, null);
			user_infoPanel.add(getUser_nameTextField(), null);
			user_infoPanel.add(getJPasswordField(), null);
			user_infoPanel.add(getJPasswordField1(), null);
			user_infoPanel.add(getCheckButton(), null);
			user_infoPanel.add(checkLabel, null);
			user_infoPanel.add(getJTextArea(), null);
			user_infoPanel.add(nameLabel, null);
			user_infoPanel.add(sexLabel, null);
			user_infoPanel.add(jLabel, null);
			user_infoPanel.add(getSex_maleRadioButton(), null);
			user_infoPanel.add(getSex_femaleRadioButton(), null);
			user_infoPanel.add(getNameTextField(), null);
			user_infoPanel.add(getAgeTextField(), null);
			user_infoPanel.add(cityLabel, null);
			user_infoPanel.add(getCityTextField(), null);
			user_infoPanel.add(telLabel, null);
			user_infoPanel.add(getTelTextField(), null);
			user_infoPanel.add(getSignatureTextField(), null);
			user_infoPanel.add(signatureLabel, null);
		}
		return user_infoPanel;
	}

	private JPanel getPw_safetyPanel() {
		if (pw_safetyPanel == null) {
			tagLabel5 = new JLabel();
			tagLabel5.setForeground(Color.magenta);
			tagLabel5.setText("*");
			tagLabel5.setLocation(new java.awt.Point(34,105));
			tagLabel5.setSize(new java.awt.Dimension(15,22));
			tagLabel5.setEnabled(false);
			tagLabel5.setFont(new Font("Dialog", Font.BOLD, 24));
			tagLabel4 = new JLabel();
			tagLabel4.setBounds(new java.awt.Rectangle(35,64,15,22));
			tagLabel4.setForeground(Color.magenta);
			tagLabel4.setText("*");
			tagLabel4.setFont(new Font("Dialog", Font.BOLD, 24));
			tagLabel4.setEnabled(false);
			tagLabel4.setVisible(true);
			noticeLabel1 = new JLabel();
			noticeLabel1.setBounds(new java.awt.Rectangle(183,14,178,28));
			noticeLabel1.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 14));
			noticeLabel1.setForeground(java.awt.Color.red);
			noticeLabel1.setText("(该设置用于找回密码!)");
			answerLabel = new JLabel();
			answerLabel.setText("提示问题答案:");
			answerLabel.setSize(new java.awt.Dimension(117,30));
			answerLabel.setFont(new java.awt.Font("黑体", java.awt.Font.PLAIN, 16));
			answerLabel.setForeground(new java.awt.Color(102,0,102));
			answerLabel.setEnabled(false);
			answerLabel.setLocation(new java.awt.Point(53,98));
			questionLabel = new JLabel();
			questionLabel.setFont(new java.awt.Font("黑体", java.awt.Font.PLAIN, 16));
			questionLabel.setSize(new java.awt.Dimension(117,30));
			questionLabel.setLocation(new java.awt.Point(53,59));
			questionLabel.setBackground(new java.awt.Color(204,204,204));
			questionLabel.setForeground(new java.awt.Color(102,0,102));
			questionLabel.setEnabled(false);
			questionLabel.setText("密码提示问题:");
			pw_safetyPanel = new JPanel();
			pw_safetyPanel.setLayout(null);
			pw_safetyPanel.setBounds(new java.awt.Rectangle(20,409,542,145));
			pw_safetyPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
			pw_safetyPanel.setFont(new java.awt.Font("黑体", java.awt.Font.PLAIN, 12));
			pw_safetyPanel.setForeground(java.awt.Color.gray);
			pw_safetyPanel.setBackground(new java.awt.Color(236,236,244));
			pw_safetyPanel.add(getPw_safetyCheckBox(), null);
			pw_safetyPanel.add(questionLabel, null);
			pw_safetyPanel.add(answerLabel, null);
			pw_safetyPanel.add(getAnswerTextField(), null);
			pw_safetyPanel.add(getNoticTextArea(), null);
			pw_safetyPanel.add(noticeLabel1, null);
			pw_safetyPanel.add(tagLabel4, null);
			pw_safetyPanel.add(tagLabel5, null);
			pw_safetyPanel.add(getQuestionsComboBox(), null);
		}
		return pw_safetyPanel;
	}

	private JButton getCmp_registerButton() {
		if (cmp_registerButton == null) {
			cmp_registerButton = new JButton();
			cmp_registerButton.setBounds(new java.awt.Rectangle(162,566,245,32));
			cmp_registerButton.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 18));
			cmp_registerButton.setForeground(java.awt.Color.blue);
			cmp_registerButton.setBackground(new java.awt.Color(226,213,223));
			cmp_registerButton.setText("完 成 注 册!");
			cmp_registerButton.addActionListener(new CmpRegListener());
		}
		return cmp_registerButton;
	}

	private JTextField getUser_nameTextField() {
		if (user_nameTextField == null) {
			user_nameTextField = new JTextField();
			user_nameTextField.setSize(new java.awt.Dimension(175,24));
			user_nameTextField.setLocation(new java.awt.Point(126,62));
		}
		return user_nameTextField;
	}

	private JPasswordField getJPasswordField() {
		if (jPasswordField == null) {
			jPasswordField = new JPasswordField();
			jPasswordField.setLocation(new java.awt.Point(126,93));
			jPasswordField.setSize(new java.awt.Dimension(175,24));
		}
		return jPasswordField;
	}

	private JPasswordField getJPasswordField1() {
		if (jPasswordField1 == null) {
			jPasswordField1 = new JPasswordField();
			jPasswordField1.setLocation(new java.awt.Point(126,123));
			jPasswordField1.setSize(new java.awt.Dimension(175,24));
		}
		return jPasswordField1;
	}

	private JButton getCheckButton() {
		if (checkButton == null) {
			checkButton = new JButton();
			checkButton.setIcon(new ImageIcon(getClass().getResource("/pictures/check.gif")));
			checkButton.setLocation(new java.awt.Point(325,62));
			checkButton.setSize(new java.awt.Dimension(27,27));
			checkButton.setBackground(new java.awt.Color(226,203,255));
			checkButton.addActionListener(new CheckListener());
		}
		return checkButton;
	}

	private JTextArea getJTextArea() {
		if (jTextArea == null) {
			jTextArea = new JTextArea();
			jTextArea.setBounds(new java.awt.Rectangle(325,95,200,50));
			jTextArea.setWrapStyleWord(true);
			jTextArea.setText("                      密码为6-16位,字母区分大小写");
			jTextArea.setToolTipText("");
			jTextArea.setLineWrap(true);
			jTextArea.setBackground(new java.awt.Color(204,255,255));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -