[Java] 注册界面 →→→→→进入此内容的聊天室

来自 , 2020-07-31, 写在 Java, 查看 158 次.
URL http://www.code666.cn/view/01882513
  1. //注册
  2. package com.view;
  3.  
  4. import java.awt.Color;
  5.  
  6. /**
  7.  * 注册界面
  8.  * @author wb2xin
  9.  *
  10.  */
  11. public class InTo_Insert extends JFrame implements ActionListener{
  12.  
  13.         /**
  14.          * 成员变量
  15.          */
  16.         private static final long serialVersionUID = 1L;
  17.         private JPanel contentPane;
  18.         //北部
  19.         JLabel topImg;
  20.         private JTextField idTex;
  21.         private JTextField ageTex;
  22.         private JButton insertBut,exitBut;
  23.         private JTextField nameTex;
  24.         private JPasswordField pswTex;
  25.         private JPasswordField pswTex1;
  26.         private JTextField pageTex;
  27.         /**
  28.          * new 出注册界面
  29.          */
  30.         public static void main(String[] args) {
  31.        
  32.                 InTo_Insert frame = new InTo_Insert();
  33.                 frame.setVisible(true);
  34.        
  35.         }
  36.  
  37.         /**
  38.          * 构造函数初始化
  39.          */
  40.         public InTo_Insert() {
  41.                 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  42.                 this.setSize(694, 498);
  43.                 this.setLocationRelativeTo(null);//居中
  44.                 contentPane = new JPanel();
  45.                 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  46.                 setContentPane(contentPane);
  47.                 contentPane.setLayout(null);
  48.                
  49.                 /**
  50.                  * top
  51.                  */
  52.                 JLabel topImage = new JLabel(new ImageIcon("image/welcome小.gif"));
  53.                 topImage.setBounds(395, 0, 283, 124);
  54.                 contentPane.add(topImage);
  55.                
  56.                 topImg = new JLabel(new ImageIcon("image/注册top.jpg"));
  57.                 topImg.setBounds(0, 0, 678, 124);
  58.                 topImg.setBackground(Color.PINK);
  59.                 contentPane.add(topImg);
  60.                
  61.                 /**
  62.                  * 中部
  63.                  */
  64.                 JLabel idLab = new JLabel("ID:");
  65.                 idLab.setHorizontalAlignment(SwingConstants.RIGHT);
  66.                 idLab.setBounds(32, 134, 52, 31);
  67.                 contentPane.add(idLab);
  68.                
  69.                 idTex = new JTextField();
  70.                 idTex.setBounds(87, 134, 83, 31);
  71.                 contentPane.add(idTex);
  72.                 idTex.setColumns(10);
  73.                
  74.                 JLabel nameLab = new JLabel("姓名:");
  75.                 nameLab.setBounds(193, 134, 53, 31);
  76.                 contentPane.add(nameLab);
  77.                
  78.                 nameTex = new JTextField();
  79.                 nameTex.setColumns(10);
  80.                 nameTex.setBounds(241, 134, 83, 31);
  81.                 contentPane.add(nameTex);
  82.                
  83.                 JLabel sexLab = new JLabel("性别:");
  84.                 sexLab.setBounds(334, 134, 53, 31);
  85.                 contentPane.add(sexLab);
  86.                
  87.                 JRadioButton sexRadio1 = new JRadioButton("男");
  88.                 sexRadio1.setBounds(373, 134, 53, 31);
  89.                 sexRadio1.setOpaque(false);
  90.                 //
  91.                 JRadioButton sexRadio2 = new JRadioButton("女");
  92.                 sexRadio2.setBounds(415, 134, 53, 31);
  93.                 sexRadio2.setOpaque(false);
  94.                 //
  95.                 ButtonGroup bg=new ButtonGroup();///
  96.                 bg.add(sexRadio1);///////
  97.                 bg.add(sexRadio2);//////////////
  98.                 sexRadio1.setSelected(true);///设置默认选项
  99.                
  100.                 contentPane.add(sexRadio1);
  101.                 contentPane.add(sexRadio2);
  102.                
  103.                 JLabel statusLab = new JLabel("申请权限:");
  104.                 statusLab.setBounds(474, 134, 77, 31);
  105.                 contentPane.add(statusLab);
  106.                
  107.                 JComboBox<Object> statusBox = new JComboBox<Object>();
  108.                 statusBox.setBounds(541, 134, 107, 31);
  109.                 statusBox.addItem("管理员");
  110.                 statusBox.addItem("学生");
  111.                 contentPane.add(statusBox);
  112.                
  113.                 JLabel pswLab = new JLabel("密码:");
  114.                 pswLab.setHorizontalAlignment(SwingConstants.RIGHT);
  115.                 pswLab.setBounds(32, 191, 52, 31);
  116.                 contentPane.add(pswLab);
  117.                
  118.                 pswTex = new JPasswordField();
  119.                 pswTex.setBounds(87, 191, 140, 31);
  120.                 contentPane.add(pswTex);
  121.                
  122.                 JLabel pswLab1 = new JLabel("密码确认:");
  123.                 pswLab1.setBounds(247, 191, 77, 31);
  124.                 contentPane.add(pswLab1);
  125.                
  126.                 pswTex1 = new JPasswordField();
  127.                 pswTex1.setBounds(315, 191, 140, 31);
  128.                 contentPane.add(pswTex1);
  129.                
  130.                 JLabel ageLab = new JLabel("年龄:");
  131.                 ageLab.setHorizontalAlignment(SwingConstants.CENTER);
  132.                 ageLab.setBounds(465, 191, 53, 31);
  133.                 contentPane.add(ageLab);
  134.                
  135.                 ageTex = new JTextField();
  136.                 ageTex.setColumns(10);
  137.                 ageTex.setBounds(514, 191, 53, 31);
  138.                 contentPane.add(ageTex);
  139.                
  140.                 JLabel ageTxet = new JLabel("岁");
  141.                 ageTxet.setHorizontalAlignment(SwingConstants.CENTER);
  142.                 ageTxet.setBounds(567, 191, 36, 31);
  143.                 contentPane.add(ageTxet);
  144.                
  145.                 JLabel pageLab = new JLabel("验证码:");
  146.                 pageLab.setHorizontalAlignment(SwingConstants.RIGHT);
  147.                 pageLab.setBounds(32, 251, 52, 31);
  148.                 contentPane.add(pageLab);
  149.                
  150.                 pageTex = new JTextField();
  151.                 pageTex.setColumns(10);
  152.                 pageTex.setBounds(87, 251, 66, 31);
  153.                 contentPane.add(pageTex);
  154.                
  155.                 JLabel explainLab = new JLabel("个人说明:");
  156.                 explainLab.setHorizontalAlignment(SwingConstants.LEFT);
  157.                 explainLab.setBounds(45, 281, 83, 31);
  158.                 contentPane.add(explainLab);
  159.                
  160.                 JScrollPane scrollPane = new JScrollPane();
  161.                 scrollPane.setBounds(43, 312, 593, 78);
  162.                 contentPane.add(scrollPane);
  163.                
  164.                 JTextArea textArea = new JTextArea();
  165.                 scrollPane.setViewportView(textArea);
  166.                
  167.                 insertBut = new JButton("注册");
  168.                 insertBut.setBounds(121, 411, 77, 31);
  169.                 insertBut.addActionListener(this);//监听1
  170.                 contentPane.add(insertBut);
  171.                
  172.                 exitBut = new JButton("返回");
  173.                 exitBut.setBounds(482, 411, 77, 31);
  174.                 exitBut.addActionListener(this);//监听1
  175.                 contentPane.add(exitBut);
  176.                
  177.                
  178.                
  179.                 this.setVisible(true);
  180.         }
  181. ///////////////////////////////////////////////////////注册监听器1
  182.         @Override
  183.         public void actionPerformed(ActionEvent de) {
  184.                 // TODO Auto-generated method stub
  185.                 if(de.getSource()==insertBut){
  186.                         //注册
  187.                        
  188.                 }else if(de.getSource()==exitBut){
  189.                         //返回
  190.                 }
  191.                
  192.         }
  193. }
  194.  

回复 "注册界面"

这儿你可以回复上面这条便签

captcha