日期:2014-05-20  浏览次数:20564 次

希望大家关注下
import java.awt.*;

import javax.swing.JFrame;
public class myframe{

public static void main(String[] args){
Frame F=new Frame("佳木斯114网库欢迎您");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
F.setSize(800,600);
F.setLocation(300,400);
F.setBackground(Color.red);
F.setVisible(true);
setLayout(new FlowLayout());
Button btn1=new Button("首页");
Button btn2=new Button("关于我们");
Button btn3=new Button("招聘");
Button btn4=new Button("行业动态");
Button btn5=new Button("联系我们");
btn1.setSize(20,40);
btn2.setSize(20,40);
btn3.setSize(20,40);
btn4.setSize(20,40);
btn5.setSize(20,40);
F.add(btn1,"North");
F.add(btn2,"South");
F.add(btn3,"West");
F.add(btn4,"East");
F.add(btn5,"Center");
F.setVisible(true);
 
}

private static void setLayout(FlowLayout flowLayout) {
// TODO Auto-generated method stub

}

private static void setDefaultCloseOperation(int disposeOnClose) {
// TODO Auto-generated method stub

运行之后怎么关闭不了窗体呢? 搞了大半天还是整不明白。请求各位大侠拔刀相助!!!

------解决方案--------------------
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
常量用错了,要用EXIT_ON_CLOSE
DO_NOTHING_ON_CLOSE(在 WindowConstants 中定义):不执行任何操作;要求程序在已注册的 WindowListener 对象的 windowClosing 方法中处理该操作。 
HIDE_ON_CLOSE(在 WindowConstants 中定义):调用任意已注册的 WindowListener 对象后自动隐藏该窗体。 
DISPOSE_ON_CLOSE(在 WindowConstants 中定义):调用任意已注册 WindowListener 的对象后自动隐藏并释放该窗体。 
EXIT_ON_CLOSE(在 JFrame 中定义):使用 System exit 方法退出应用程序。仅在应用程序中使用。