存储结构还没弄好
package Main;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Main extends JFrame {
String s1, s2, s3, s4;
String str1,str2,str3;
JLabel jLabel1, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7,
jLabel8, jLabel9, jLabel10, jLabel11, jLabel12, jLabel13, jLab4,
jLabel15, jLabel16, jLabel17, jLabel18, jLabel19;
JButton jButton1, jButton2, jButton3, jButton4, jButton5, jButton6,
jButton7, jButton8, jButton9, jButton10, jButton11, jButton12,
jButton13, jButton14, jButton15, jButton16, jButton17, jButton18,
jButton19, jButton20;
JTextField jTextField1, jTextField2, jTextField3, jTextField4, jTextField5;
JPasswordField jPasswordField1, jPasswordField2, jPasswordField3,
jPasswordField4, jPasswordField5;
public Main() {
// 主界面
this.setTitle("主界面");
this.setSize(600, 600);
this.setLocation(300, 200);
this.setLayout(null);
this.setVisible(true);
this.setVisible(true);
// 主界面内容
jLabel1 = new JLabel("用户登录注册系统");
jLabel1.setBounds(230, 100, 200, 50);
jButton1 = new JButton("登录");// 按键
jButton2 = new JButton("注册");
jButton3 = new JButton("退出");
jButton1.setBounds(180, 200, 200, 50);
jButton2.setBounds(180, 300, 200, 50);
jButton3.setBounds(180, 400, 200, 50);
this.add(jLabel1);
this.add(jButton1);
this.add(jButton2);
this.add(jButton3);
// 登录界面
jButton1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame f1 = new JFrame("登录界面");
f1.setSize(500, 500);
f1.setLocation(200, 200);
f1.setLayout(null);
f1.setVisible(true);
// 登录界面内容
jLabel2 = new JLabel("用户名 :");//
jLabel2.setBounds(100, 50, 100, 50);
jTextField1 = new JTextField("");
jTextField1.setText("");
jTextField1.setBounds(150, 50, 200, 50);
jLabel3 = new JLabel("密码");
jLabel3.setBounds(100, 150, 100, 50);
jPasswordField1 = new JPasswordField();
jPasswordField1.setText("");
jPasswordField1.setBounds(150, 150, 200, 50);
jButton4 = new JButton("登录");
jButton5 = new JButton("取消");
jButton4.setBounds(150, 270, 70, 50);
jButton5.setBounds(250, 270, 70, 50);
f1.add(jLabel2);
f1.add(jTextField1);
f1.add(jLabel3);
f1.add(jPasswordField1);
f1.add(jButton4);
f1.add(jButton5);
jButton4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final String s1 = jTextField2.getText();
final String s2 = jPasswordField2.getText();
final String s3 = jPasswordField3.getText();
final String s4 = jTextField3.getText();
final String str = jTextField1.getText();
final String str2 = jPasswordField1.getText();
if (s1.equals(str) ) {
final JFrame f5 = new JFrame("当前登录");// 窗口
f5.setSize(600, 600);
f5.setLocation(200, 200);
f5.setLayout(null);
f5.setVisible(true);
jLabel10 = new JLabel("选择如下操作:");//
jLabel10.setBounds(20, 50, 100, 50);
jButton10 = new JButton("显示详细信息");
jButton11 = new JButton("修改个人资料");
jButton12 = new JButton("退出");
jButton10.setBounds(120, 90, 200, 100);
jButton11.setBounds(120, 230, 200, 100);
jButton12.setBounds(120, 360, 200, 100);
f5.add(jLabel10);
f5.add(jButton10);
f5.add(jButton11);
f5.add(jButton12);
jButton11.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
final JFrame f6 = new JFrame("修改界面");// 窗口
f6.setSize(500, 400);
f6.setLocation(200, 200);
f6.setLayout(null);
f6.setVisible(true);
jLabel15 = new JLabel("新密码:");// 面板1
jLabel15.setBounds(10, 30, 100, 30);
jPasswordField4 = new JPasswordField("");
jPasswordField4.setText("");
jPasswordField4.setBounds(80, 30, 200, 25);
jLabel16 = new JLabel("确定密码:");// 面板1
jLabel16.setBounds(10, 80, 100, 30);
jPasswordField5 = new JPasswordField("");
jPasswordField5.setText("");
jPasswordField5.setBounds(80, 80, 200, 25);
jLabel17 = new JLabel("新编号:");
jLabel17.setBounds(10, 130, 100, 30);
jTextField5 = new JTextField("");
jTextField5.setText("");
jTextField5.setBounds(80, 130, 200, 25);
jButton17 = new JButton("确定修改");
jButton18 = new JButton("退出");
jButton17.setBounds(70, 270, 100, 50);
jButton18.setBounds(200, 270, 100, 50);
f6.add(jLabel15);
f6.add(jPasswordField4);
f6.add(jLabel16);
f6.add(jPasswordField5);
f6.add(jLabel17);
f6.add(jTextField5);
f6.add(jButton17);
f6.add(jButton18);
jButton17.addActionListener(new ActionListener() {
@Override
public void actionPerformed(
ActionEvent arg0) {
// TODO Auto-generated
// method stub
String str1=new String(jPasswordField4.getText());
String str2=new String(jPasswordField5.getText());
String str3=new String(jTextField5.getText());
if(str1.equals(str2)){
final JFrame f7=new JFrame("消息");
f7.setSize(400, 400);
f7.setLocation(200, 200);
f7.setLayout(null);
f7.setVisible(true);
jLabel18=new JLabel("修改成功");
jLabel18.setBounds(120, 80, 100, 50);
jButton19 = new JButton("确定");
jButton19.setBounds(100, 150, 100, 50);
f7.add(jLabel18);
f7.add(jButton19);
jButton19.addActionListener(new ActionListener() {
@SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent e) {
f7.setVisible(false);
}
});
}else{
final JFrame f8=new JFrame("消息");
f8.setSize(400, 400);
f8.setLocation(200, 200);
f8.setLayout(null);
f8.setVisible(true);
jLabel19=new JLabel("密码不一致");
jLabel19.setBounds(120, 80, 100, 50);
jButton20 = new JButton("确定");
jButton20.setBounds(100, 150, 100, 50);
f8.add(jLabel19);
f8.add(jButton20);
jButton20.addActionListener(new ActionListener() {
@SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent e) {
f8.setVisible(false);
}
});
}
}
});
jButton18.addActionListener(new ActionListener() {
@Override
public void actionPerformed(
ActionEvent arg0) {
// TODO Auto-generated
// method stub
f6.setVisible(false);
}
});
}
});
jButton12.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
f5.setVisible(false);
}
});
jButton10.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final JDialog dialog = new JDialog(f5, "消息");
jButton16 = new JButton("确定");// 对话框
dialog.setLocation(200, 200);
dialog.setSize(400, 400);
dialog.add(jButton16);
jButton16.setBounds(100, 300, 60, 60);
jLabel11 = new JLabel("您的详细资料为:");
jLabel12 = new JLabel("账号:" + s1);
jLabel13 = new JLabel("密码:" + s2);
jLab4 = new JLabel("编号:" + s4);
dialog.add(jLabel11);
dialog.add(jLabel12);
dialog.add(jLabel13);
dialog.add(jLab4);
jLabel11.setBounds(120, 20, 100, 100);
jLabel12.setBounds(120, 60, 100, 100);
jLabel13.setBounds(120, 100, 100, 100);
jLab4.setBounds(120, 140, 100, 100);
dialog.setVisible(true);
jButton16
.addActionListener(new ActionListener() {
@Override
public void actionPerformed(
ActionEvent arg0) {
// TODO Auto-generated
// method stub
dialog.setVisible(false);
}
});
}
});
} else {
final JFrame f5 = new JFrame("消息");
f5.setSize(400, 200);
f5.setLocation(200, 200);
f5.setLayout(null);
f5.setVisible(true);
jLabel11 = new JLabel("账号或密码输入错误");
jLabel11.setBounds(160, 30, 200, 50);
jButton13 = new JButton("确定");
jButton13.setBounds(160, 100, 70, 30);
f5.add(jLabel11);
f5.add(jButton13);
jButton13.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
f5.setVisible(false);
}
});
}
}
});
}
});
// 注册界面
jButton2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFrame f2 = new JFrame("注册界面");// 窗口
f2.setSize(600, 600);
f2.setLocation(200, 200);
f2.setLayout(null);
f2.setVisible(true);
// 注册界面内容
jLabel4 = new JLabel("用户名 :");//
jLabel4.setBounds(140, 50, 100, 50);
jTextField2 = new JTextField("");
jTextField2.setText("");
jTextField2.setBounds(200, 50, 200, 50);
jLabel5 = new JLabel("密码 :");//
jLabel5.setBounds(140, 110, 100, 50);
jPasswordField2 = new JPasswordField();
jPasswordField2.setText("");
jPasswordField2.setBounds(200, 110, 200, 50);
jLabel6 = new JLabel("确认密码 :");//
jLabel6.setBounds(120, 170, 100, 50);
jPasswordField3 = new JPasswordField();
jPasswordField3.setText("");
jPasswordField3.setBounds(200, 170, 200, 50);
jLabel7 = new JLabel("编号 :");//
jLabel7.setBounds(140, 230, 100, 50);
jTextField3 = new JTextField("");
jTextField3.setText("");
jTextField3.setBounds(200, 230, 200, 50);
jButton6 = new JButton("确定");
jButton7 = new JButton("取消");
jButton6.setBounds(180, 360, 120, 50);
jButton7.setBounds(330, 360, 120, 50);
f2.add(jLabel4);
f2.add(jTextField2);
f2.add(jLabel5);
f2.add(jPasswordField2);
f2.add(jLabel6);
f2.add(jPasswordField3);
f2.add(jLabel7);
f2.add(jTextField3);
f2.add(jButton6);
f2.add(jButton7);
jButton6.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String s1 = jTextField2.getText();
String s4 = jTextField3.getText();
@SuppressWarnings("deprecation")
String s2 = jPasswordField2.getText();
@SuppressWarnings("deprecation")
String s3 = jPasswordField3.getText();
if (s2.equals(s3)) {
final JFrame f3 = new JFrame("消息");
f3.setSize(400, 200);
f3.setLocation(200, 200);
f3.setLayout(null);
f3.setVisible(true);
jLabel8 = new JLabel("注册成功");
jLabel8.setBounds(160, 30, 100, 50);
jButton8 = new JButton("确定");
jButton8.setBounds(160, 100, 70, 30);
f3.add(jLabel8);
f3.add(jButton8);
jButton8.addActionListener(new ActionListener() {
@SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent e) {
f3.setVisible(false);
}
});
} else {
final JFrame f4 = new JFrame("消息");
f4.setSize(400, 200);
f4.setLocation(200, 200);
f4.setLayout(null);
f4.setVisible(true);
jLabel9 = new JLabel("输入密码不一致");
jLabel9.setBounds(160, 30, 100, 50);
jButton9 = new JButton("确定");
jButton9.setBounds(160, 100, 70, 30);
f4.add(jLabel9);
f4.add(jButton9);
jButton9.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
f4.setVisible(false);
}
});
}
}
});
jButton7.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jTextField2.setText("");
jPasswordField2.setText("");
jPasswordField3.setText("");
jTextField3.setText("");
}
});
}
});
// 退出界面
jButton3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
}