Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - is there a way to hide the close button in a swing application?

Tags:

java

swing

is there a way to hide the close button in a swing application?

I know I can set JFrame.DO_NOTHING_ON_CLOSE but is there a way to eliminate it completely?

if I write setUndecorated(true) I get
IllegalComponentStateException - the frame is displayable

like image 415
Bick Avatar asked Apr 10 '11 08:04

Bick


Video Answer


1 Answers

Using frame.setUndecorated(true) while the frame has already been displayed leads to an error as this is not allowed in the API. Instead, use frame.setUndecorated(true) before you set frame.setVisible(true). This should solve your error:

IllegalComponentStateException - the frame is displayable

If you are successful, the close button will be hidden.

like image 51
Dhruv Gairola Avatar answered Oct 24 '22 18:10

Dhruv Gairola