File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JDialog X Button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog X Button" Watch "JDialog X Button" New topic

JDialog X Button

Karen Baog
Ranch Hand

Joined: Mar 02, 2005
Posts: 120
Hi all,

How do I get rid of the X button on the top right corner of a JDialog box?

Thanks to all.

amerzil co-ed student<br />"Praise be the Code"
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

You can't. You can disable it though. setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); That way, when the user hits the X, nothing will happen.

GenRocket - Experts at Building Test Data
Karen Baog
Ranch Hand

Joined: Mar 02, 2005
Posts: 120
Hi guys,

How do I catch the event when the User clicks on the X button ?

Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
You need to register a WindowListener, as far as I remember.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Scott Delap
Ranch Hand

Joined: Apr 05, 2005
Posts: 73
You might check this out:

Customizing Window Adornments
I agree. Here's the link:
subject: JDialog X Button
jQuery in Action, 3rd edition