📄 registrggui.java
字号:
//***********************************注 册*************************************
import javax.swing.*;
import java.awt.*;
import java.net.*;
import java.awt.color.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import java.io.*;
public class RegistrgGUI extends JFrame implements ActionListener
{
JLabel label1;
JLabel labelName;
JLabel label01;
JLabel label02;
JLabel labelAge;
JLabel labelSex;
JLabel label2;
JLabel labelpfA;
JLabel label03;
JLabel labelpfB;
JLabel label3;
JLabel labelCountry;
JLabel jl;
JLabel labelProvince;
JLabel jla;
JLabel labelCity;
JLabel jlab;
JLabel label4;
JLabel label04;
JLabel label05;
JLabel label06;
JLabel label07;
JLabel label08;
JButton jb;
JButton jb1;
JTextField txtName;
JTextField txtAge;
JTextField txt08;
JTextField txt06;
JPasswordField labelpfa;
JPasswordField labelpfb;
ButtonGroup bg;
JRadioButton rb1; //
JRadioButton rb2; //if()
JComboBox comboBox1;
JComboBox comboBox2;
JComboBox comboBox3;
JComboBox CBmonth;
JComboBox comboBox5;
Socket soc;
UserRegistrg ur;
ClientItf client;
boolean bo;
static ResultSet pid;
static Connection con;
static PreparedStatement stat;
public RegistrgGUI(ClientItf c1)
{
super (" 小布点聊天室--------注 册 ");
client = c1;
ur = new UserRegistrg();
Container c = this.getContentPane();
JPanel p = new JPanel();
GridBagLayout gb = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
p.setLayout(gb);
c.add(p);
label1 = new JLabel (" 您 的 基 本 信 息 ");
labelName = new JLabel (" * 昵 称 : ",10);
label01 = new JLabel ("请输入您的昵称");
label02 = new JLabel ("1-12个字符,每个汉字或全角字符算2个字符");
labelAge = new JLabel (" * 年 龄 : ",10);
labelSex = new JLabel (" * 性 别 : ",10);
label2 = new JLabel ("为您的号码设置一个密码 ");
labelpfA = new JLabel (" * 密 码 : ",10);
label03 = new JLabel ("6-10个字符组成但不能为9位纯数字");
labelpfB = new JLabel ("重新输入密码:");
label3 = new JLabel (" 您 的 所 在 地 区: ");
labelCountry = new JLabel (" * 国 家 : ",10);
jl = new JLabel ("请选择所在国家");
labelProvince = new JLabel (" * 省 份 : ",10);
jla = new JLabel ("请选择您所在省份");
labelCity = new JLabel (" * 城 市 : ",10);
jlab = new JLabel ("请您选择您所在城市");
label4 = new JLabel (" 设 置 机 密 问 题(2个) " );
label04 = new JLabel ("您知道机密问题有什么用吗?当此帐号修改密码时会要求您回答机密问题,这将确保是您本人在进行密码修改操作,使您的帐号更安全。");
label05 = new JLabel (" 问 题 1 ",10);
label06 = new JLabel ("答案1:");
label07 = new JLabel (" 问 题2 ",10);
label08 = new JLabel ("答案2");
//ButtonListener buttonlistener=new ButtonListener(); //******加 事 件
jb = new JButton("完成");
jb1= new JButton("返回");
jb.addActionListener(this);
jb1.addActionListener(this);
txtName = new JTextField(15);
txtAge = new JTextField(15);
txt08 = new JTextField(15);
txt06 = new JTextField(15);
labelpfa = new JPasswordField(15);
labelpfb = new JPasswordField(15);
p.setToolTipText ("Registration is welcome!--欢迎注册小布点聊天室!");
txtName.setToolTipText ("请在这儿输入昵称 ");
txtAge.setToolTipText ("请在这儿输入年龄 ");
labelpfa.setToolTipText ("请在这儿输入密码 ");
labelpfb.setToolTipText ("请在这儿重新输入密码 ");
txt06.setToolTipText ("请在这儿输入第一个问题的答案 ");
txt08.setToolTipText ("请在这儿输入第二个问题的答案 ");
label01.setForeground(Color.red);//*************************添加字体颜色
jl.setForeground(Color.red);
jla.setForeground(Color.red);
jlab.setForeground(Color.red);
labelName.setForeground(Color.red);
//labelAge.setForeground(Color.red);
labelSex.setForeground(Color.red);
labelpfA.setForeground(Color.red);
labelCountry.setForeground(Color.red);
labelProvince.setForeground(Color.red);
labelCity.setForeground(Color.red);
labelpfB.setForeground(Color.red);
label05.setForeground(Color.red);
label07.setForeground(Color.red);
label1.setForeground(Color.blue);
label2.setForeground(Color.blue);
label3.setForeground(Color.blue);
label4.setForeground(Color.blue);
bg = new ButtonGroup();
rb1 = new JRadioButton("男",true);
//if(rb1.isSelected()){user.setSex("男");}
rb2 = new JRadioButton("女");
bg.add(rb1);
bg.add(rb2);
Font f = new Font("黑体",Font.BOLD+Font.ROMAN_BASELINE,20);
Font f1 = new Font("黑体",Font.BOLD+Font.TYPE1_FONT,15);
label1.setFont(f);
label2.setFont(f);
label3.setFont(f);
label4.setFont(f);
label04.setFont(f1);
Icon i = new ImageIcon("autumn.gif");
Icon ii = new ImageIcon("2006sjb.GIF");
// Icon iii = new ImageIcon("C:/Documents and Settings/Administrator/桌面/下载图片/20060906483220.GIF");
JLabel llblTop02 = new JLabel(i);
JLabel llblTop = new JLabel(ii);
llblTop.setIcon(i);
llblTop02.setIcon(ii);
this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("6516959_1.jpg")));
p.setBackground(Color.gray);
p.setBorder(BorderFactory.createLineBorder(Color.gray,7));
labelName.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY,2));
comboBox1 = new JComboBox();
comboBox1.addItem("中国");
comboBox1.addItem("美国");
comboBox1.addItem("日本");
comboBox1.addItem("加拿大");
comboBox1.addItem("印度");
comboBox2 = new JComboBox();
comboBox2.addItem("台湾省");
comboBox2.addItem("青海省");
comboBox2.addItem("甘肃省");
comboBox2.addItem("湖南省");
comboBox2.addItem("云南省");
comboBox2.addItem("四川省");
comboBox2.addItem("海南省");
comboBox2.addItem("广东省");
comboBox2.addItem("河北省");
comboBox2.addItem("湖北省");
comboBox2.addItem("福建省");
comboBox2.addItem("江苏省");
comboBox2.addItem("吉林省");
comboBox2.addItem("华盛顿");
comboBox2.addItem("东京");
comboBox2.addItem("渥太华");
comboBox2.addItem("达卡");
comboBox2.addItem("新德里");
comboBox2.addItem("科伦坡");
comboBox2.addItem("更多^^^");
comboBox3 = new JComboBox();
comboBox3.addItem("台北");
comboBox3.addItem("西宁");
comboBox3.addItem("兰州");
comboBox3.addItem("长沙市");
comboBox3.addItem("昆明");
comboBox3.addItem("成都");
comboBox3.addItem("海口");
comboBox3.addItem("广州");
comboBox3.addItem("石家庄");
comboBox3.addItem("武汉");
comboBox3.addItem("福州");
comboBox3.addItem("南京");
comboBox3.addItem("长春");
comboBox3.addItem("纽约");
comboBox3.addItem("芝加哥");
comboBox3.addItem("波斯顿");
comboBox3.addItem("休斯顿");
comboBox3.addItem("旧金山");
comboBox3.addItem("底特律");
comboBox3.addItem("仙台");
comboBox3.addItem("关东");
comboBox3.addItem("大阪");
comboBox3.addItem("长崎");
comboBox3.addItem("温哥华");
comboBox3.addItem("温尼伯");
comboBox3.addItem("孟加拉");
comboBox3.addItem("加尔各答");
comboBox3.addItem("班加罗尔");
comboBox3.addItem("孟买");
comboBox3.addItem("马累");
comboBox3.addItem("更多^^^");
CBmonth = new JComboBox();
CBmonth.addItem("1.您的生日?");
CBmonth.addItem("2.您的地址?");
CBmonth.addItem("3.您母亲的生日");
CBmonth.addItem("4.您父亲的生日?");
comboBox5 = new JComboBox();
comboBox5.addItem("1.您的生日?");
comboBox5.addItem("2.您的小学地址?");
comboBox5.addItem("3.您的小学老师?");
comboBox5.addItem("4.您父亲的生日?");
gbc.gridx = 0;
gbc.gridy = 4;
gbc.gridwidth = 1;
gbc.gridheight =1;
gb.setConstraints(llblTop,gbc);
p.add(llblTop);
gbc.gridx = 0;
gbc.gridy = 8;
gbc.gridwidth = 1;
gbc.gridheight =1;
gb.setConstraints(llblTop02,gbc);
p.add(llblTop02);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.insets = new Insets(0,0,5,5);
gb.setConstraints(label1,gbc);
p.add(label1);
gbc.gridx = 1;
gbc.gridy = 1;
gb.setConstraints(labelName,gbc);
p.add(labelName);
gbc.gridx = 2;
gbc.gridy = 1;
gb.setConstraints(txtName,gbc);
p.add(txtName);
gbc.gridx = 3;
gbc.gridy = 1;
gb.setConstraints(label01,gbc);
p.add(label01);
gbc.gridx = 2;
gbc.gridy = 2;
gb.setConstraints(label02,gbc);
p.add(label02);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -