dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: User Interface Design
Expertise: Beginner
Apr 5, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


JFrame Exit Button

Question:
Is it possible to remove the close button from a JFrame or at least disable it?

Answer:
It is possible to disable the function of the close button on a JFrame, but it does not appear to be possile to remove it. The close button is placed by the native windowing system, and there do not seem to be any API hooks provided to tell the windowing system not to draw the button.

The easiest way to disable the close action on a JFrame is to call its setDefaultCloseOperation(). This method accepts an integer as a parameter representing the operation to perform. This value must be one of the constants defined in the WindowConstants interface. Using the value WindowConstans.DO_NOTHING_ON_CLOSE will do the trick. You will notice that JFrame implements the WindowConstants interface, so it is also possible to use JFrame.DO_NOTHING_ON_CLOSE, which may be clearer. Note, however, that JInternalFrame provides the ability to control the presence or absence of an exit button.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date