Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4223014

JOptionPane.setInputValue() spec incorrectly insinuates initializing default

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.0
    • client-libs
    • 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)
      ======================================================================

            amfowler Anne Fowler (Inactive)
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: