Reputation: 18511
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
Upvotes: 7
Views: 2188
Reputation: 9182
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.
Upvotes: 6