How do you add a ActionListener
to the close button (not a JButton
the button on the top-right)?
Asked
Active
Viewed 1,675 times
1

Reaz Murshed
- 23,691
- 13
- 78
- 98

jjtraversy
- 11
- 5
-
if (Display.isCloseRequested()) { // DO STUFF } – flotothemoon Apr 25 '14 at 16:26
-
Im getting an error from display – jjtraversy Apr 25 '14 at 17:58
1 Answers
4
See Closing an Application for a discussion on this topic and a couple of solutions.
Basically you need to do two things:
- Use the
setDefaultCloseOperation(...)
of the frame. - Add a
WindowListener
to the frame

camickr
- 321,443
- 19
- 166
- 288