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

REGRESSION: NullPointerException when updating UI of JComboBox.

XMLWordPrintable

    • b62
    • x86
    • windows_xp

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

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

      A DESCRIPTION OF THE PROBLEM :
      Exception is thrown when updating UI of JComboBox:

      Exception in thread "main" java.lang.NullPointerException
      at javax.swing.plaf.basic.BasicComboBoxUI.uninstallUI(BasicComboBoxUI.java:262)
      at javax.swing.JComponent.setUI(JComponent.java:643)
      at javax.swing.JComboBox.setUI(JComboBox.java:238)
      at javax.swing.JComboBox.updateUI(JComboBox.java:247)
      at lt.monarch.swing.JDateField$DateComboBox.updateUI(JDateField.java:987)
      at lt.monarch.swing.JDateField.setCalendarHorizontalAlignment(JDateField.java:223)
      at DateTest.<init>(DateTest.java:87)
      at DateTest.main(DateTest.java:49)

      And here is code snippet from source code distributed with jdk 1.5:

      (javax\swing\plaf\basic\BasicComboBoxUI.java)

      261: if ( comboBox.getEditor() == null || comboBox.getEditor() instanceof UIResource ) {
      262: if(comboBox.getEditor().getEditorComponent().hasFocus()) {
      263: // Leave focus in JComboBox.
      264: comboBox.requestFocusInWindow();
      265: }
      266: comboBox.setEditor( null );
      267: }

      If editor of combobox is 'null', condition of first 'if' statement is satisfied.
      So, program tries to check the condition of second 'if' statement and
      throws NullPointerException, when trying to call method of editor, which actually is 'null'.

      Updating has worked fine with 1.3.x and 1.4.x java versions.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.NullPointerException
      at javax.swing.plaf.basic.BasicComboBoxUI.uninstallUI(BasicComboBoxUI.java:262)
      at javax.swing.JComponent.setUI(JComponent.java:643)
      at javax.swing.JComboBox.setUI(JComboBox.java:238)
      at javax.swing.JComboBox.updateUI(JComboBox.java:247)
      at lt.monarch.swing.JDateField$DateComboBox.updateUI(JDateField.java:987)
      at lt.monarch.swing.JDateField.setCalendarHorizontalAlignment(JDateField.java:223)
      at DateTest.<init>(DateTest.java:87)
      at DateTest.main(DateTest.java:49)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 10/29/04 22:03 GMT

            draskinsunw Daniel Raskin (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: