Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to remove a close button from the title bar of a window?



An easier way, avoiding the subclass is to use:

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/ JFrame.html#setDefaultCloseOperation(int)

as in setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

Unfortunately there's no way to actually HIDE the close button, that I know of :(

Another approach is to implement WindowListener, and override windowClosing(). In windowClosing() you call the same method that gets called when your custom JButton is pressed.

I'd still rather be able to turn off the close button, because when the dialog has multiple buttons its difficult for the user to guess which the close button is equivalent to:

|------------------------------------|
| x |
|------------------------------------|
| Do you want to save your changes? |
| |
| [Don't Save] [Cancel] [Save] |
|------------------------------------|

How is the poor user supposed to guess which button the 'x' is equivalent to in this dialog?

So your two options are:

* make the close button do nothing at all (crap)

* force the user to guess which action is taken if they click the close button (also crap)

Which just goes to show why you should never let Sun Microsystems design a UI.

AndyT

On Mar 18, 2004, at 8:47 AM, Romann Christoph wrote:

Hello Alex

We created our on Dialog which extends Jdialog.

Within our own class we overridden
protected void processWindowEvent(WindowEvent e).
Since then no closing events happend any more and our modal dialog stays as long as we wish.

Hope this helps.

Regards,

Chris


-----Original Message-----
From: email@hidden [mailto:email@hidden] On Behalf Of Alexander Lamb
Sent: Donnerstag, 18. Mdrz 2004 14:19
To: email@hidden
Subject: How to remove a close button from the title bar of a window?


Hello,

I have a JDialog which is opened as modal.
I need the title bar to display something and enable the user to move the window around. I also want to allow resizing. However, I don't want to allors closing with the close button, but only from a JButton I implemented.

In the constructor I do:

setUndecorated(false);
getRootPane().setWindowDecorationStyle(JRootPane.NONE);

The problem is that if I use setUndecorated(true), I also loose the title bar, the resizing and moving capability.

I found nowhere a setting which would say something like:

isCloseButtonEnabled(false) for example.

Thanks,

Alex
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.


AndyT (lordpixel - the cat who walks through walls)
A little bigger on the inside

(see you later space cowboy ...)
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.