帮我查看一下哪里出的问题importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassLoginWindowextendsFrameimplementsActionListener{TextFielduserID,password;Lo...
帮我查看一下哪里出的问题
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class LoginWindow extends Frame implements ActionListener {
TextField userID, password;
LoginWindow() {
super("用户登录窗口");
setLayout(new GridLayout(3,1));
Panel p1=new Panel();
Label label1 = new Label("用户名: ");
userID = new TextField(12);
p1.add(label1);
p1.add(userID);
Panel p2=new Panel();
Label label2 = new Label("密 码: ");
password = new TextField(12);
password.setEchoChar('*');
p2.add(label2);
p2.add(password);
Panel p3=new Panel();
Button submit = new Button(" 提 交 ");
Button reset = new Button(" 重 置 ");
submit.addActionListener(this);
reset.addActionListener(this);
p3.add(submit);
p3.add(reset);
add(p1);
add(p2);
add(p3);
addWindowListener(new WindowMonitor());
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals(" 提 交 ")) {
if(userID.getText().equals("software") && password.getText().equals("87818998")) {
Frame f = new Frame("新窗口");
f.setSize(400,300);
f.setVisible(true);
f.addWindowListener(new WindowMonitor());
}
else {
JOptionPane.showMessageDialog(null, "帐号、密码不正确!");
}
}
if(e.getActionCommand().equals(" 重 置 ")) {
userID.setText("");
password.setText("");
}
}
public static void main(String argc[]) {
LoginWindow myframe = new LoginWindow();
myframe.pack();
myframe.setVisible(true);
}
}
class WindowMonitor extends WindowAdapter {
public void WindowClosing(WindowEvent e) {
System.exit(0);
}
}
展开