JDK-4105948 : JOptionPane REALLY Needs Conditional Dismissal
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0,6
  • Priority: P5
  • Status: Open
  • Resolution: Unresolved
  • OS: generic,windows_95,windows_nt
  • CPU: generic,x86
  • Submitted: 1998-01-22
  • Updated: 2013-05-15
Description
Name: rm29839			Date: 01/22/98


Hello,

We really need a way to prevent a JOptionPane
from automatically closing when the user presses
one of the option buttons. Currently, the
JOptionPane has an anonymous class in the 
'createDialog()' method that automatically
dispose()es of the dialog.

Here're two reasons why we need this feature:

1) Many times, even usually, it is necessary to
validate user input in a dialog after they press
the "OK" button. If the user has entered incorrect
data, we want to tell them about it and then send
control right back to the dialog so they can make
the corrections.  I don't want the dialog to be
dismissed just to display it again so the user
can make corrections.

2) Very often a dialog will have a "Reset" or
"Default" button that fills in some standard,
pre-defined sets of values.  It doesn't seem
reasonable to have that dialog dismissed just
because a "Reset" button was pressed.  The user
may very well need to change only a couple values
from their standard, defaults.  The current
implemntation dismisses the dialog as soon as the
"Default" button is pressed.

If this isn't clear, please let me know.  The
current implementation of JOptionPane is
essentially useless since it automatically
dismisses itself.

I have a few ideas on how to implement this as
well (since I have to do it myself, anyway :)

Thanks very much.
(Review ID: 23713)
======================================================================

Comments
EVALUATION Contribution-Forum:https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?messageID=11291&forumID=1463
08-02-2006

EVALUATION [aim 3/17/98] This is a reasonable request. The workaround in the meantime is to just build your own option dialog by putting a JOptionPane inside a JDialog (and then managing all windowing operations yourself). ralph.kar@Eng 1998-11-11 More input from another user: Using the createDialog() function, as I thought that the evalutation suggested, is not working as I thought. The dialog returned does not fire any window events, and I don't see how to use this window to provide any kind of conditional closing mechanism. Am I missing something? Also, do I need to dispose of the frame I create to call the createDialog function. And, if so, how do I know when to do this...or this forced to be in the pervue of the calling object.
24-09-2004