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

Null Arrow Button Throws Exception in BasicComboBoxUI

    Details

    • Subcomponent:
    • Resolved In Build:
      b30
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Not verified

      Backports

        Description

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

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows 2000 [Version 5.00.2195]

        A DESCRIPTION OF THE PROBLEM :
        In the class BasicComboBoxUI in the method installComponents() will throw a NullPointerException if the createArrowButton() returns null. The installComponents() method does check if it is null before it calls the configureArrowButton(). All that is needed is the call to comboBox.add( arrowButton ); be placed inside the null check. Like this:

        protected void installComponents() {
            arrowButton = createArrowButton();
        // comboBox.add( arrowButton ); //move this line from here

             if (arrowButton != null) {
                comboBox.add( arrowButton ); // to here
                configureArrowButton();
            }

            if ( comboBox.isEditable() ) {
                addEditor();
            }

            comboBox.add( currentValuePane );
        }

        import javax.swing.*;
        import javax.swing.plaf.basic.*;
        public class Test{
          protected static class TestBasicComboBoxUI extends BasicComboBoxUI{
            protected JButton createArrowButton() {
              return null;
            }
          }
          public static void main(String[] args) {
            JComboBox combobox = new JComboBox();
            combobox.setUI(new TestBasicComboBoxUI());
          }
        }


        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Exception in thread "Thread-6" java.lang.NullPointerException
        at java.awt.Container.addImpl(Container.java:1019)
        at java.awt.Container.add(Container.java:351)
        at javax.swing.plaf.basic.BasicComboBoxUI.installComponents(BasicComboBoxUI.java:646)
        at javax.swing.plaf.basic.BasicComboBoxUI.installUI(BasicComboBoxUI.java:230)
        at javax.swing.JComponent.setUI(JComponent.java:650)
        at javax.swing.JComboBox.setUI(JComboBox.java:238)
        at mil.navy.spawar.rcp.gui.dialerboard.dialer.table.InformationTableCellEditor.createPresetTypeComboBox(InformationTableCellEditor.java:68)
        at mil.navy.spawar.rcp.gui.dialerboard.dialer.table.InformationTableCellEditor.<init>(InformationTableCellEditor.java:57)
        at mil.navy.spawar.rcp.gui.dialerboard.dialer.MultipleDialerPanel.getInformationTable(MultipleDialerPanel.java:309)
        at mil.navy.spawar.rcp.gui.dialerboard.dialer.MultipleDialerPanel.getInformationScrollPane(MultipleDialerPanel.java:333)
        at mil.navy.spawar.rcp.gui.dialerboard.dialer.MultipleDialerPanel.getDataPanel(MultipleDialerPanel.java:208)
        at mil.navy.spawar.rcp.gui.dialerboard.dialer.AbstractDialerPanel.getMainSplitPane(AbstractDialerPanel.java:145)
        at mil.navy.spawar.rcp.gui.dialerboard.dialer.AbstractDialerPanel.<init>(AbstractDialerPanel.java:81)
        at mil.navy.spawar.rcp.gui.dialerboard.dialer.MultipleDialerPanel.<init>(MultipleDialerPanel.java:59)
        at mil.navy.spawar.rcp.gui.dialerboard.DialerboardPanel.getMultipleDialerPanel(DialerboardPanel.java:130)
        at mil.navy.spawar.rcp.gui.dialerboard.DialerboardPanel$1.run(DialerboardPanel.java:86)
        at java.lang.Thread.run(Thread.java:595)


        REPRODUCIBILITY :
        This bug can be reproduced always.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  alitvinov Anton Litvinov
                  Reporter:
                  jssunw Jitender S (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: