📄 majorsrs.java
字号:
package Srs;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import Srs.AfterLoad;
import Srs.LinkDatabase;
import Srs.GetPassword;
import Srs.Regist;
public class MajorSrs extends JFrame implements ActionListener{
private JTextField textField_2;
private JTextField textField_1;
/**
* Launch the application
* @param args
*/
/**
* Create the frame
*/
private JButton button = new JButton();
private JButton button_1 = new JButton();
private JLabel label = new JLabel();
private JLabel label_1 = new JLabel();
private JLabel label_2 = new JLabel();
private JPasswordField passwordField = new JPasswordField();
private JTextField textField = new JTextField();
private JButton button_2 = new JButton();
private LinkDatabase linkDatabase = new LinkDatabase();
public MajorSrs(){
this.init();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //关闭窗口时退出程序
}
public void init() {
getContentPane().setLayout(null);
setBounds(100, 100, 500, 375);
this.setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
button.setText("登陆");
button.setFont(new Font("楷体_GB2312", Font.BOLD, 18));
button.setBounds(151, 269, 82, 28);
getContentPane().add(button);
button.addActionListener(this);
button_1.setText("取消");
button_1.setFont(new Font("楷体_GB2312", Font.BOLD, 18));
button_1.setBounds(268, 269, 82, 28);
getContentPane().add(button_1);
button_1.addActionListener(this);
label.setFont(new Font("楷体_GB2312", Font.BOLD, 24));
label.setComponentPopupMenu(null);
label.setText("欢迎来到北京航空航天大学学生注册系统");
label.setBounds(25, 10, 457, 79);
getContentPane().add(label);
label_1.setFont(new Font("楷体_GB2312", Font.BOLD, 18));
label_1.setText("用户名:");
label_1.setBounds(134, 117, 89, 35);
getContentPane().add(label_1);
label_2.setFont(new Font("楷体_GB2312", Font.BOLD, 18));
label_2.setText("密码:");
label_2.setBounds(134, 190, 89, 35);
getContentPane().add(label_2);
textField.setBounds(223, 122, 140, 28);
getContentPane().add(textField);
passwordField.setBounds(223, 195, 140, 29);
getContentPane().add(passwordField);
button_2.setFont(new Font("楷体_GB2312", Font.BOLD, 11));
button_2.setForeground(new Color(128, 128, 128));
button_2.setText("注册");
button_2.setBounds(420, 308, 62, 23);
getContentPane().add(button_2);
button_2.addActionListener(this);
//
}
public JTextField getJTextField(){
return this.textField;
}
public JPasswordField getJPasswordField(){
return this.passwordField;
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == button){
if(!this.textField.getText().equals("")&&
!String.valueOf(this.passwordField.getPassword()).equals("")){
GetPassword get = new GetPassword();
char[] x = this.passwordField.getPassword();
String z = String.valueOf(x);
String y = get.getPassword(this.textField.getText());
if(y == null){
JOptionPane newone = new JOptionPane();
newone.showMessageDialog(null, " "+"用户名或密码错误"+
"\n"+"若未注册,请注册后登陆");
}
else{
int m = Integer.parseInt(z);
int n = Integer.parseInt(y);
if(m == n){
AfterLoad afterload = new AfterLoad(this.textField.getText());
this.setVisible(false);
afterload.setVisible(true);
}
else{
JOptionPane newone = new JOptionPane();
newone.showMessageDialog(null, " "+"用户名或密码错误"+
"\n"+"若未注册,请注册后登陆");
}
}
}
else{
JOptionPane newone = new JOptionPane();
newone.showMessageDialog(null, "用户名或密码不能为空");
}
}
else if(e.getSource() == button_1){
this.textField.setText("");
this.passwordField.setText("");
}
else if(e.getSource() == button_2){
Regist regist = new Regist();
this.setVisible(false);
regist.setVisible(true);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -