添加了WindowClosing,代码也没有出错为什么窗体关闭不了importjava.awt.*;importjava.awt.event.*;publicclassUserLogin{publicUserLogin(){Framef=newFrame();f.setTitle("用户登录...
添加了WindowClosing,代码也没有出错为什么窗体关闭不了
import java.awt.* ;
import java.awt.event.* ;
public class UserLogin{
public UserLogin(){
Frame f = new Frame() ;
f.setTitle("用户登录窗口") ;
f.setVisible(true);
f.setLayout(new GridLayout(3,1));
Panel pl1 = new Panel() ;
Panel pl2 = new Panel() ;
Panel pl3 = new Panel() ;
Label username = new Label("用户名:") ;
TextField usertext = new TextField(20) ;
pl1.add(username) ;
pl1.add(usertext) ;
Label password = new Label("密"+" "+"码:") ;
TextField passtext = new TextField(20) ;
passtext.setEchoChar('*') ;
pl2.add(password) ;
pl2.add(passtext) ;
Button bt1 = new Button("提交") ;
Button bt2 = new Button("重置") ;
pl3.add(bt1) ;
pl3.add(bt2) ;
f.add(pl1) ;
f.add(pl2) ;
f.add(pl3) ;
f.pack() ;
f.addWindowListener(new WindowAdapter(){
public void WindouClosing(WindowEvent e){
System.exit(0);
}
});
}
public static void main(String[] args){
UserLogin ul = new UserLogin() ;
}
}
展开