aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to disable or remove Close Button on JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to disable or remove Close Button on JFrame" Watch "How to disable or remove Close Button on JFrame" New topic
Author

How to disable or remove Close Button on JFrame

Bhagya Tangutur
Ranch Hand

Joined: Oct 21, 2002
Posts: 88
How to disable or remove Close Button on JFrames???


Sun Certified Java Programmer
VIJAY Yadlapati
Ranch Hand

Joined: Aug 04, 2003
Posts: 175
You can't remove close Button from JFrames, but you can disable by calling setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE) on that JFrame.
Bhagya Tangutur
Ranch Hand

Joined: Oct 21, 2002
Posts: 88
Yes...I am already calling that function.My concern is It doen't look like it's disabled.so i wanna change it's icon or i totally wanna remove that close button.because it is just misleads to the user.
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Actually you could try this but I really don't think it's what you want, it's going to remove all window decorations (there will be no title bar, etc.) and I'm not even sure if it's supported on all platforms. I don't think it works on pre 1.4 either.

Also look into JWindow which is similar, no titlebar with buttons and what not.
[ August 10, 2003: Message edited by: Ken Blair ]
Bhagya Tangutur
Ranch Hand

Joined: Oct 21, 2002
Posts: 88
Ken,
your right ...it doesn't work prior to jdk1.4.
besides,I want to keep all other buttons,Title(Frame/Window decorations).Thanks for u r sussestion,I came to know something new with your posting.
Benson Fung
Ranch Hand

Joined: Apr 10, 2003
Posts: 207
Hi,

Use JWindow instead of JFrame, the 3 buttons won't appear on JWindow.

Benson
sean van buggenum
Greenhorn

Joined: May 16, 2008
Posts: 7
hi all,

I know this is an old thread now, but i found it while searching for the answer to the problem myself. I post this here as I found this way the best for me, perhaps someone else searching for this finds it useful..

I posted my solution here:

http://forum.java.sun.com/thread.jspa?messageID=10255068

16th of May 2008
3:35 PM
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36476
    
  16
Welcome to JavaRanch, Sean.
Thank you. Actually there are ways to remove the X button from a JFrame, somebody showed us how last year, but I can't remember when.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36476
    
  16
I ahve found the old thread with details of how to remove the close button: here.
Pairach Gestongma
Greenhorn

Joined: Nov 11, 2012
Posts: 1
i try

her her
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
and what are you trying to do?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to disable or remove Close Button on JFrame
 
Similar Threads
disableing 'x' button
Popup window close button
popup window
Disabling minimize and maximie button
Disabling the 'X' button of JDialog