jframe关闭当前窗口的方法有哪些

avatar
作者
猴君
阅读量:6

  1. 使用WindowListener接口实现窗口关闭事件:
frame.addWindowListener(new WindowAdapter() {     @Override     public void windowClosing(WindowEvent e) {         frame.dispose();     } }); 
  1. 通过调用dispose()方法关闭窗口:
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 
  1. 使用System.exit(0)关闭窗口及应用程序:
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!