编译提示只要在javac后加个参数 -d 就可以了要能关掉窗口,需要在构造函数中加入以下代码
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
即:
public GUITest()
{
super("Test GUI");
setLayout(new BorderLayout());
add("South",new Button ("确定"));
pack();
resize(height,width);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
show();
}
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
即:
public GUITest()
{
super("Test GUI");
setLayout(new BorderLayout());
add("South",new Button ("确定"));
pack();
resize(height,width);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
show();
}
应该改为
class GUITest extends JFrame你试试吧
....setDefaultCloseOperation(EXIT_ON_CLOSE);