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

javax.swing.JRadioButton(Action a) ignores params

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: sdC67446 Date: 10/15/99


      The method
          protected void configurePropertiesFromAction(Action a)
      of class
          javax.swing.JRadioButton
      doesn't take the icon property from the 'a'.

      The doc says:
      --------------------------------------------------
      protected void configurePropertiesFromAction(Action a)

       Factory method which sets the ActionEvent source's properties
       according to values from the Action instance. The properties which
       are set may differ for subclasses. By default, the properties which
       get set are Text, Icon, Enabled, and ToolTipText.

       Overrides:
           configurePropertiesFromAction in class AbstractButton
       Parameters:
           a - the Action from which to get the properties, or null
       Since:
           1.3
       See Also:
           Action, AbstractButton.setAction(javax.swing.Action)

      the demo test:
      --------------------------------------------------
      import javax.swing.*;
      import java.awt.event.*;
      import java.beans.PropertyChangeListener;

      public class Test {

          
          public static class FakeJRadioButton extends JRadioButton {
              public void configurePropertiesFromAction(Action a) {
                  super.configurePropertiesFromAction(a);
              }
          }

          public static class FakeAction implements Action {
              
              private String name;
              private Icon icon;
              private String short_description;
              private boolean isEnabled;
              
              public FakeAction(String name,
                                Icon icon,
                                String short_description,
                                boolean isEnabled) {
                  this.name = name;
                  this.icon = icon;
                  this.short_description = short_description;
                  this.isEnabled = isEnabled;
              }
              
              public Object getValue(String key) {
                  if (key.equals(Action.NAME)) {
                      return name;
                  } else if (key.equals(Action.SMALL_ICON)) {
                      return icon;
                  } else if (key.equals(Action.SHORT_DESCRIPTION)) {
                      return short_description;
                  } else {
                      return null;
                  }
              }
              public void putValue(String key, Object value) {}
              public void setEnabled(boolean b) {isEnabled = b;}
              public boolean isEnabled() {return isEnabled;}
              public void addPropertyChangeListener(PropertyChangeListener listener) {}
              public void removePropertyChangeListener(PropertyChangeListener listener) {}
              public void actionPerformed(ActionEvent e) {}
          }

          public static void main(String argv[]) {
              String name = "name";
              Icon icon = new ImageIcon();
              String short_description = "short_description";
              boolean isEnabled = true;

              FakeAction action =
                  new FakeAction(name, icon, short_description, isEnabled);
              FakeJRadioButton rb = new FakeJRadioButton();
              rb.configurePropertiesFromAction(action);
              System.out.println("getText(): "+rb.getText()+", "+name);
              System.out.println("getIcon(): "+rb.getIcon()+", "+icon);
              System.out.println("getToolTipText(): "+rb.getToolTipText()+", "+short_description);
              System.out.println("isEnabled(): "+rb.isEnabled()+", "+isEnabled);
          }
      }

      output:
      --------------------------------------------------
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      Font specified in font.properties not found [-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific]
      getText(): name, name
      getIcon(): null, javax.swing.ImageIcon@6a9d42
      getToolTipText(): short_description, short_description
      isEnabled(): true, true
      --------------------------------------------------
      ======================================================================

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: