How to set an action for a close button?

I created a standalone Java application in NetBeans 6.9. I want to set an action for the close button of my application. I want to know how and where to set the code for the action of this close button. Can anyone help me in this regard?

+5
source share
6 answers

You need to register the ActionListener on the close button. In this listener, you can determine what to do.

How to add ActionListener to JButton in Java Swing

+4
source

Right click on the button, then > Events > Action > actionPerformed. NetBeanswill generate an action listener for you :)

: , .

+2
+2
+2

, ( , Windows, !!!)

  • - .
  • ...

, , , , ( ) , , , , , , , /, , /.

, ( , ), ,

+2

, ,

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Oracle

0

All Articles