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

使用WindowListener接口实现窗口关闭事件:

frame.addWindowListener(new WindowAdapter() {
    @Override
    public void windowClosing(WindowEvent e) {
        frame.dispose();
    }
});

通过调用dispose()方法关闭窗口:

frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

使用System.exit(0)关闭窗口及应用程序:

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
阅读剩余
THE END