Terminate running threads on JFrame close

前端 未结 3 2096
北荒
北荒 2021-02-09 11:19

How do I invoke extra operations when the user closes a JFrame window? I have to stop existing threads.

As I understand it, setDefaultCloseOperation(J

3条回答
  •  半阙折子戏
    2021-02-09 11:46

    You can set the default close operation on the JFrame

    JFrame frame = new JFrame("My Frame");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    

提交回复
热议问题