-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
merlin
-
generic
-
generic
Name: vi73552 Date: 03/23/99
The JDialog created from JOptionPane.createDialog(java.awt.Frame, java.lang.String) does not display the inputValue when set with JOptionPane.setInputValue(java.lang.String) .
The text field *seems* to contain the set inputValue (as it refuses to allow the same input to be entered again when pressing return), but it is not editable or visible. It does, however exist -- if the text field remains unedited, the set inputValue will be returned by JOptionPane.getInputValue() .
In order to see the bug in action, run the following code and press the okay button without typing anything:
import javax.swing.JOptionPane;
import javax.swing.JDialog;
public class JOptionBug
{
static String[] options = {"OK"};
JOptionPane inputPane;
JDialog dialog;
public JOptionBug()
{
inputPane = new JOptionPane("Simply press ok now...", JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[0]);
inputPane.setWantsInput(true);
inputPane.setInputValue("This value will not appear in the text field");
dialog = inputPane.createDialog((java.awt.Frame)null, "JOptionBug demonstration");
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.setModal(true);
dialog.setVisible(true);
System.out.println((String)inputPane.getInputValue());
System.exit(0);
}
public static void main(String[] args)
{
new JOptionBug();
}
}
(Review ID: 55918)
======================================================================