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

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 completely fix it?

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

+7
source share
1 answer

Using frame.setUndecorated(true) while the frame has already been displayed results in an error, as this is not valid in the API . Instead, use frame.setUndecorated(true) before setting frame.setVisible(true) . This should solve your error:

IllegalComponentStateException - frame is displayed

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

+6
source

All Articles