This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes how to remove the window close icon. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to remove the window close icon." Watch "how to remove the window close icon." New topic
Author

how to remove the window close icon.

Sachindra Pratap
Ranch Hand

Joined: Jun 03, 2008
Posts: 42
hi,
In my swing application ,i want to remove the close icon which comes at upper right cornor of the window.
I want to logout my application, by making use of logout button which i have put.

please convey the solution!.

regards
Sachindra
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10172
    
    8

Originally posted by Sachindra Pratap:
hi,
In my swing application ,i want to remove the close icon which comes at upper right cornor of the window.
I want to logout my application, by making use of logout button which i have put.

please convey the solution!.

regards
Sachindra


I dont think it is possible to do this without messing around with the ComponentUI.

However, if you set the which is the default behavior and add your own window listener, you can get notified when the user attempts to close the application window and process the event the way you want to.
[ September 18, 2008: Message edited by: Maneesh Godbole ]

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You can use JWindow or JFrame.setUndecorated(true) - however, both of these options remove all frame decorations - titlebar, icon, minimize button, maximize button, and close button.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Ted Smyth
Ranch Hand

Joined: May 28, 2008
Posts: 73
I'm too lazy to search for the thread(s) about this topic (but you certainly are welcome to, I think there's at least two with relevant code/discussion), but here's a bit of code I found that seems to work in L&Fs excluding the Windows L&F on XP; it removes all buttons on the title bar:



Call it with the frame you want to remove buttons on.

I would have to recommend Mr. Godbole's suggestion if you are planning to deploy an app on XP.


Edward Smith
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
Please do a search through this forum; a similar subject came up about a year ago, with lots of code to show how it can be done.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10172
    
    8

I think this is the one.
http://www.coderanch.com/t/344419/GUI/java/deactivate-close-minimise-resizable-window
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
Yes, Maneesh, that is the thread I was thinking of. Well done finding it
Sachindra Pratap
Ranch Hand

Joined: Jun 03, 2008
Posts: 42
Thankyou all of you!

regards
Sachindra
 
jQuery in Action, 2nd edition
 
subject: how to remove the window close icon.
 
Similar Threads
perform a specific task on logout/closing of browser
How to Close multiple child windows from a parent window
Logout Code is not working
How to set an icon to jnlp window?
logOut script not working