package 学生管理系统;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MainClass extends JFrame {
public MainClass() {
super("学生管理系统---管理员登陆");
this.init();
}
public void init() {
Container cp = this.getContentPane();
cp.setLayout(null);
JLabel jlabel1 = new JLabel("管理员帐号:");
JLabel jlabel2 = new JLabel("管理员密码:");
JButton jbutton = new JButton("登陆");
final JTextField text = new JTextField(10);
final JPasswordField password = new JPasswordField();
jbutton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String[] str =
new DatabaseUtilities().getDataTypes("Admin_info");
if(str[0].equals(text.getText()))
if(str[1].equals(password.getText()))
JOptionPane.showMessageDialog(f,"你以管理员"
+str[0]+"的身份登陆"); //这里有错误,该怎么办。。。意思是不认识F
else
JOptionPane.showMessageDialog(f,"你输入的密码有误");
else
JOptionPane.showMessageDialog(f,"你输入的用户名不存在");
}
});
cp.add(jlabel1);
cp.add(jlabel2);
cp.add(text);
cp.add(password);
cp.add(jbutton);
jlabel1.setBounds(150, 150, 100, 20);
jlabel2.setBounds(150, 200, 100, 20);
text.setBounds(260, 150, 150, 20);
password.setBounds(260, 200, 150, 20);
jbutton.setBounds(220, 270, 90, 40);
this.setSize(new Dimension(600, 400));
this.setLocation(200, 200);
this.show();
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
/*class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
String SQLCommand = "SELECT * FROM Admin_info";
execute(SQLCommand);
}
}*/
public static void main(String[] args) {
final MainClass f = new MainClass();
}
}