Discussion:
JOptionPane - Hide the "X" button
(too old to reply)
Alex V.
2006-05-31 15:45:17 UTC
Permalink
Is there a way to hide/mask/not show the X (close) of the window when
showing a JOptionPane.showMessageDialog ?

Thank you !
Steve W. Jackson
2006-05-31 18:47:36 UTC
Permalink
Post by Alex V.
Is there a way to hide/mask/not show the X (close) of the window when
showing a JOptionPane.showMessageDialog ?
Thank you !
Not really, no. Most of the methods of JOptionPane create the dialog
for you and use a platform-native appearance for the title bar,
decorations, etc. Even if you make your own dialog from JDialog,
they'll be decorated by default. You can set them undecorated, but then
you have the additional responsibility of providing your own title bar,
and I suspect you don't want that.

What you probably really want to do is what the vast majority of
programs do, which is to simply construct a dialog that doesn't respond
to the decoration.
--
Steve W. Jackson
Montgomery, Alabama
Thomas A. Russ
2006-05-31 23:12:43 UTC
Permalink
Post by Steve W. Jackson
Post by Alex V.
Is there a way to hide/mask/not show the X (close) of the window when
showing a JOptionPane.showMessageDialog ?
Why do you want to make a message dialog that the user can't close?

There is a real benefit to following the standard conventions of the
system you are using.
Post by Steve W. Jackson
Not really, no. Most of the methods of JOptionPane create the dialog
for you and use a platform-native appearance for the title bar,
decorations, etc. Even if you make your own dialog from JDialog,
they'll be decorated by default. You can set them undecorated, but then
you have the additional responsibility of providing your own title bar,
and I suspect you don't want that.
But that really is what needs to be done to have a quality interface.
(Either that or lobby for finer control over the window view).

Perhaps the best thing to do would be to simply hide the window on close
instead of getting rid of it. Then, if your program needs to put it up
again, it can.
Post by Steve W. Jackson
What you probably really want to do is what the vast majority of
programs do, which is to simply construct a dialog that doesn't respond
to the decoration.
I think this is a terrible suggestion.

The whole point of having and using consistent interface elements is so
that the user can predict what will happen when they do various things.
If you keep the decoration but disable the function, this will only
serve to confuse and annoy your users. You really don't want to do
that, do you?
--
Thomas A. Russ, USC/Information Sciences Institute
Loading...