Link to home
Start Free TrialLog in
Avatar of mattjulius
mattjulius

asked on

Removing JFrame Close Button

I have an application which I have to remove the close button of the title bar of JFrame...can anybody help me.....
Avatar of mbvvsatish
mbvvsatish
Flag of Canada image

try doing this

setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
or use Jwindow instead of JFrame
You can use JFrame.setUndecorated(true) and JFrame.getRootPane().setWindowDecorationStyle(some_style_without_close_button), but this will only work if the current windowing system supports disabling native decorations (MS Windows does), and if the current look-and-feel supports window decorations. A quick test (in J2SE 1.4.2) shows that:

Metal LAF -- supports
Motif LAF -- does not support
Windows LAF -- does not support

i got this info from web, please check it once.
try this, this will disable the close button.
JFrame.this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
Avatar of mattjulius
mattjulius

ASKER

What I wanna do is to remove the close button totally..
ASKER CERTIFIED SOLUTION
Avatar of mbvvsatish
mbvvsatish
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What is the issue with undecorated? You want the other buttons like minimize to be present?
The issue w/ undecotated is it will also remove the titlebar wherein i just want to remove the close button.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial