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.....
Java

Avatar of undefined
Last Comment
hoomanv

8/22/2022 - Mon
mbvvsatish

try doing this

setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
mbvvsatish

or use Jwindow instead of JFrame
mbvvsatish

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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
mbvvsatish

try this, this will disable the close button.
JFrame.this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
mattjulius

ASKER
What I wanna do is to remove the close button totally..
ASKER CERTIFIED SOLUTION
mbvvsatish

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Mayank S

What is the issue with undecorated? You want the other buttons like minimize to be present?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
mattjulius

ASKER
The issue w/ undecotated is it will also remove the titlebar wherein i just want to remove the close button.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.