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

BasicComboBoxUI.isPopupVisible returns NullPointerException

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b12
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_03"
      Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      javax.swing.plaf.basic.BasicComboBoxUI.isPopupVisible(BasicComboBoxUI.java:825) returns NullPointerException when called from a overridden method of getModel().

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      If a class extends JComboBox and Overrides getModel(). Then it calls isPopupVisible() from the overriden getModel() it gets NullPointerException the first time. Because the popup variable in javax.swing.plaf.basic.BasicComboBoxUI is not set yet.
      I think that the isPopupVisible() should have an "if (popup == null) return false;". Because the menu isn't visible yet, if it is not even setup.

      ACTUAL -
      NullPointerException

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
              at javax.swing.plaf.basic.BasicComboBoxUI.isPopupVisible(BasicComboBoxUI.java:825)
              at javax.swing.JComboBox.isPopupVisible(JComboBox.java:807)
              at combo.getModel(combo.java:29)
              at javax.swing.plaf.basic.BasicComboPopup.createList(BasicComboPopup.java:467)
              at javax.swing.plaf.basic.BasicComboPopup.<init>(BasicComboPopup.java:313)
              at javax.swing.plaf.basic.BasicComboBoxUI.createPopup(BasicComboBoxUI.java:393)
              at javax.swing.plaf.metal.MetalComboBoxUI.createPopup(MetalComboBoxUI.java:148)
              at javax.swing.plaf.basic.BasicComboBoxUI.installUI(BasicComboBoxUI.java:217)
              at javax.swing.JComponent.setUI(JComponent.java:673)
              at javax.swing.JComboBox.setUI(JComboBox.java:238)
              at javax.swing.JComboBox.updateUI(JComboBox.java:247)
              at javax.swing.JComboBox.init(JComboBox.java:212)
              at javax.swing.JComboBox.<init>(JComboBox.java:206)
              at combo.<init>(combo.java:24)
              at NewJFrame.initComponents(NewJFrame.java:29)
              at NewJFrame.<init>(NewJFrame.java:17)
              at NewJFrame$2.run(NewJFrame.java:77)
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
              at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.ComboBoxModel;
      import javax.swing.JComboBox;

      // use this JComboBox in a frame

      public class combo extends JComboBox
      {
          public combo()
          {
      super();
          }
          @Override
          public ComboBoxModel getModel()
          {
      isPopupVisible();
      return super.getModel();
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            Assignee:
            psadhukhan Prasanta Sadhukhan
            Reporter:
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: