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

inconsistency in JToolBar.createActionComponent

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.6



      Name: sdC67446 Date: 10/25/99


      The method
          protected JButton createActionComponent(Action a)
      of class
          javax.swing.JToolBar
      throws undefined NullPointerException if 'a' == null.

      The other similar methods:
        AbstractButton.configurePropertiesFromAction(Action a)
        AbstractButton.createActionPropertyChangeListener(Action a)
        JRadioButton.createActionPropertyChangeListener(Action a)
        JRadioButton.configurePropertiesFromAction(Action a)

      accept input null action and set the values:
        1) getText()
        2) getIcon()
        3) getToolTipText()
        4) isEnabled()

      by default.
      The documentation for these methods clarify the null-reaction.

      It is inconsistency in the JToolBar.createActionComponent(Action).

      The doc says:
      ------------------------------------------------------------
      protected JButton createActionComponent(Action a)

            Factory method which creates the JButton for Actions added to
            the JToolBar.
            Parameters:
                  a - the Action for the button to be added
            See Also:
                  Action

      demo test:
      --------------------------------------------------
      import javax.swing.*;

      public class Test extends JToolBar {

          public JButton createActionComponent(Action a) {
              return super.createActionComponent(a);
          }

          public static void main(String argv[]) {
              new Test().createActionComponent(null);
          }
      }

      output:
      --------------------------------------------------
      Exception in thread "main" java.lang.NullPointerException
              at javax.swing.JToolBar.createActionComponent(JToolBar.java:444)
              at Test.createActionComponent(Test.java:6)
              at Test.main(Test.java:11)
      --------------------------------------------------
      ======================================================================

            peterz Peter Zhelezniakov
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: