我用WINDOW加载了ID这个面板后,无论密码正确与否它都调用了RESET();晕~~``~WINDOW这个窗口无法关闭,我用System.exit(0);却不主窗口都给关闭了 ),倒!!!!!!!!!!!!!!
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class ID extends JPanel implements ActionListener{
JPanel s=new JPanel();
JPanel t=new JPanel();
JPanel q=new JPanel();
JPanel r=new JPanel();
JLabel kl=new JLabel("kouling");
JLabel mm=new JLabel("mima");
JTextField klh=new JTextField(30);
JTextField mmh=new JTextField(30);
JButton submit=new JButton("Submit");
JButton reset=new JButton("Reset");
public ID(){
s.setLayout(new GridLayout(2,1));
s.add(kl);
s.add(mm);
q.setLayout(new GridLayout(2,1));
q.add(klh);
q.add(mmh);
r.setLayout(new GridLayout(1,2));
r.add(s);
r.add(q);
t.setLayout(new FlowLayout(FlowLayout.CENTER));
t.add(submit);
t.add(reset);
submit.addActionListener(this);
reset.addActionListener(this);
this.setLayout(new GridLayout(2,1));
this.add(r);
this.add(t);
klh.addActionListener(this);
mmh.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
String Command=e.getActionCommand();
if(Command.equals("Submit"))
{submit();}
else
if(Command.equals("Reset")){
reset();
}
}
public void reset(){
klh.setText("");
mmh.setText("");
}
public void submit(){
String kouling=klh.getText();
String name=mmh.getText();
if("yfzsj2161"==klh.getText()&&"yfzsj1025"==klh.getText())
System.exit(0);
else
reset();
}
}