Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set action for close button?

I've created a stand-alone java desktop application in Netbeans 6.9. I want to set the action for the close button of my application. I want to know how and where to set the code for the action of that close button. Can anyone please help me regarding this?

like image 971
user594860 Avatar asked Feb 06 '11 11:02

user594860


People also ask

How do you make a close button?

A close button is a <button> element with the class . close-button . We use the multiplication symbol ( &times; ) as the X icon. This icon is wrapped in a <span> with the attribute aria-hidden="true" , so screen readers don't read the X icon.

How do you create a close button in HTML?

Add a close button using HTML, CSS, and JavaScriptCreate a button element in your creative using a <div> tag. Create the element in the HTML file and style it in the CSS file. Then assign the ID close-btn to your element.

What is the function of the Close button?

(eXit button) Also called a "close" or "exit" button, clicking or tapping the X removes the current window, dialog box or popup message from the screen. It is also used to delete text and graphics.


2 Answers

You have to register an ActionListener on your close button. In this listener you can define what do to.

How add ActionListener to JButton in Java Swing

like image 97
RoflcoptrException Avatar answered Sep 22 '22 09:09

RoflcoptrException


I think answers for How to close a java swing application from the code will be helpful too

like image 32
Maxim Welikobratov Avatar answered Sep 20 '22 09:09

Maxim Welikobratov