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

JOptionPane show dialog methods have bad doc for first parameter

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • 1.4.1
    • client-libs

      New description:
      ----------------
      Multiple JOptionPane methods contain bad documentation for the first parameter. Original bug report shown below. See evaluation for a pointer to the methods with bad doc.

      Original description:
      ---------------------
      Name: jk109818 Date: 01/07/2003


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)


      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Tested under NetBeans

      A DESCRIPTION OF THE PROBLEM :
      According to the docs I can pass null as the parent
      component to JOptionPane.showInternalConfirmDialog(). But
      the following line of code executed from a visible GUI:

      JOptionPane dialog = new JOptionPane();
      dialog.showInternalConfirmDialog(null, new String(""));

      throws a Runtime Exception with the following:

      java.lang.RuntimeException: JOptionPane: parentComponent
      does not have a valid parent
              at
      javax.swing.JOptionPane.createInternalFrame(JOptionPane.java:1347)



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the source code and click on the button.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I expected a dialog panel to appear, what I got what a
      runtime exception

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid
      parent
              at javax.swing.JOptionPane.createInternalFrame(JOptionPane.java:1347)
              at javax.swing.JOptionPane.showInternalOptionDialog(JOptionPane.java:1186)
              at javax.swing.JOptionPane.showInternalConfirmDialog(JOptionPane.java:1122)
              at javax.swing.JOptionPane.showInternalConfirmDialog(JOptionPane.java:1083)
              at javax.swing.JOptionPane.showInternalConfirmDialog(JOptionPane.java:1046)
              at javax.swing.JOptionPane.showInternalConfirmDialog(JOptionPane.java:1018)
              at TAL.Test.jButton1ActionPerformed(Test.java:34)
              at TAL.Test.access$100(Test.java:5)
              at TAL.Test$2.actionPerformed(Test.java:23)
              at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
              at
      javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
              at
      javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
              at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
              at
      javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
              at java.awt.Component.processMouseEvent(Component.java:5093)
              at java.awt.Component.processEvent(Component.java:4890)
              at java.awt.Container.processEvent(Container.java:1566)
              at java.awt.Component.dispatchEventImpl(Component.java:3598)
              at java.awt.Container.dispatchEventImpl(Container.java:1623)
              at java.awt.Component.dispatchEvent(Component.java:3439)
              at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
              at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
              at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
              at java.awt.Container.dispatchEventImpl(Container.java:1609)
              at java.awt.Window.dispatchEventImpl(Window.java:1585)
              at java.awt.Component.dispatchEvent(Component.java:3439)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
              at
      java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
              at
      java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
      ^C

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import javax.swing.*;

      public class Test extends javax.swing.JFrame {
        
        public Test() {
          initComponents();
        }
        
        private void initComponents() {
          jButton1 = new javax.swing.JButton();

          addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
              exitForm(evt);
            }
          });

          jButton1.setText("jButton1");
          jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
              jButton1ActionPerformed(evt);
            }
          });

          getContentPane().add(jButton1, java.awt.BorderLayout.CENTER);

          pack();
        }

        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
          JOptionPane dialog = new JOptionPane();
          int ok = dialog.showInternalConfirmDialog(null, new String(""));
        }
        
        private void exitForm(java.awt.event.WindowEvent evt) {
          System.exit(0);
        }
        
        public static void main(String args[]) {
          new Test().show();
        }
        private javax.swing.JButton jButton1;
      }
      ---------- END SOURCE ----------
      (Review ID: 167321)
      ======================================================================

            Unassigned Unassigned
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: