📄 ragistermessage.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package testgui;import DBOperation.*;import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.io.*;/** * * @author RJ-408 */public class RagisterMessage extends JDialog implements ActionListener{ JLabel 用户名,性别,密码,确认密码,学校,年级; JTextField 用户名1,性别1,学校1,年级1; JPasswordField 密码1,确认密码1; JButton 确定,取消; public RagisterMessage() { super(); this.setLayout(null); 用户名=new JLabel("用 户 名"); 性别=new JLabel("性 别"); 密码=new JLabel("密 码"); 确认密码=new JLabel("确认密码"); 学校=new JLabel("学 校"); 年级=new JLabel("年 级"); 用户名1=new JTextField(20); 性别1=new JTextField("男"); 学校1=new JTextField("首都师范大学"); 年级1=new JTextField("2006"); 密码1=new JPasswordField(20); 确认密码1=new JPasswordField(20); 确定=new JButton("确定"); 取消=new JButton("取消"); this.add(用户名); this.add(性别); this.add(密码); this.add(确认密码); this.add(用户名1); this.add(性别1); this.add(密码1); this.add(确认密码1); this.add(确定); this.add(取消); this.add(学校); this.add(年级); this.add(学校1); this.add(年级1); 确定.addActionListener(this); 取消.addActionListener(this); 用户名.setBounds(10, 20, 100, 20); 性别.setBounds(10, 40, 100, 20); 密码.setBounds(10, 60, 100, 20); 确认密码.setBounds(10, 80, 100, 20); 学校.setBounds(10, 100, 100, 20); 年级.setBounds(10, 120, 100, 20); 用户名1.setBounds(120, 20, 200, 20); 性别1.setBounds(120, 40, 200, 20); 密码1.setBounds(120, 60, 200, 20); 确认密码1.setBounds(120, 80, 200, 20); 学校1.setBounds(120, 100, 200, 20); 年级1.setBounds(120, 120, 200, 20); 确定.setBounds(150, 170, 80, 20); 取消.setBounds(240, 170, 80, 20); this.setBounds(220, 220, 350, 230); this.setVisible(false); } public RagisterMessage(Landing land) { super(land,"用户注册",false); this.setLayout(null); 用户名=new JLabel("用 户 名"); 性别=new JLabel("性 别"); 密码=new JLabel("密 码"); 确认密码=new JLabel("确认密码"); 学校=new JLabel("学 校"); 年级=new JLabel("年 级"); 用户名1=new JTextField(20); 性别1=new JTextField("男"); 学校1=new JTextField("首都师范大学"); 年级1=new JTextField("2006"); 密码1=new JPasswordField(20); 确认密码1=new JPasswordField(20); 确定=new JButton("确定"); 取消=new JButton("取消"); this.add(用户名); this.add(性别); this.add(密码); this.add(确认密码); this.add(用户名1); this.add(性别1); this.add(密码1); this.add(确认密码1); this.add(确定); this.add(取消); this.add(学校); this.add(年级); this.add(学校1); this.add(年级1); 确定.addActionListener(this); 取消.addActionListener(this); 用户名.setBounds(10, 20, 100, 20); 性别.setBounds(10, 40, 100, 20); 密码.setBounds(10, 60, 100, 20); 确认密码.setBounds(10, 80, 100, 20); 学校.setBounds(10, 100, 100, 20); 年级.setBounds(10, 120, 100, 20); 用户名1.setBounds(120, 20, 200, 20); 性别1.setBounds(120, 40, 200, 20); 密码1.setBounds(120, 60, 200, 20); 确认密码1.setBounds(120, 80, 200, 20); 学校1.setBounds(120, 100, 200, 20); 年级1.setBounds(120, 120, 200, 20); 确定.setBounds(150, 170, 80, 20); 取消.setBounds(240, 170, 80, 20); this.setBounds(220, 220, 350, 230); this.setVisible(false); } public void actionPerformed(ActionEvent e) { if(e.getSource()==取消) this.setVisible(false); if(e.getSource()==确定) { DBUser dbUser=new DBUser(); int sex=1,power=2; String password=""; if(性别1.getText().equals("男")) sex=1; else sex=2;// password=密码1.getPassword(); if(this.toString(密码1.getPassword()).equals(this.toString(确认密码1.getPassword()))) { password=this.toString(密码1.getPassword()); dbUser.UserAdd(用户名1.getText(), sex, password, power, 学校1.getText()); } else { String About="您两次输入的密码不一致,请重新输入 "; JOptionPane.showMessageDialog(this,About,"警告",JOptionPane.WARNING_MESSAGE); 密码1.setText(null); 确认密码1.setText(null); }/* for(int i=0;i<word.length;i++) pass=pass+word[i];*/ this.setVisible(false); } throw new UnsupportedOperationException("Not supported yet."); } public String toString(char[] p) { String password=""; char pass[]=p; for(int i=0;i<pass.length;i++) password=password+pass[i]; return password; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -