窗体没有加入监听器?
public class Demo10 {
public static void main(String[] args) {
JFrame f = new JFrame();
f.addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("hello");
System.exit(1);
}
});
f.setVisible(true);
f.setLocationRelativeTo(null);
}
}
温馨提示:答案为网友推荐,仅供参考