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

Introspector cannot find the "focusable" property.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.1
    • 1.4.0
    • client-libs
    • None
    • hopper
    • x86
    • windows_nt

      The focusable property is new in 1.4 and is a boolean and bound property implemented in Component with isFocusable and setFocusable. For some reason, this property is not picked up by the Introspector all allong the class heirarchy.

      The MethodDescriptors for a BeanInfo can find the isFocusable()/setFocusable() methods as part of the set.

      This has never worked from the earliest days of merlin.

      import java.awt.*;
      import java.beans.*;
      import javax.swing.*;

      public class Focusable {

          public static void main(String[] args) {
      hasProperty(Component.class, "focusable");
      hasProperty(Container.class, "focusable");
      hasProperty(JComponent.class, "focusable");
      hasProperty(AbstractButton.class, "focusable");
      hasProperty(JButton.class, "focusable");
      hasProperty(JToggleButton.class, "focusable");

      // Control set. "enabled" and "name" can be found
      hasProperty(Component.class, "enabled");
      hasProperty(Container.class, "enabled");
      hasProperty(JComponent.class, "enabled");
      hasProperty(AbstractButton.class, "enabled");
      hasProperty(JButton.class, "enabled");
      hasProperty(JToggleButton.class, "enabled");

      hasProperty(Component.class, "name");
      hasProperty(Container.class, "name");
      hasProperty(JComponent.class, "name");
      hasProperty(AbstractButton.class, "name");
      hasProperty(JButton.class, "name");
      hasProperty(JToggleButton.class, "name");


          }

          public static boolean hasProperty(Class cls, String property) {
      boolean result = true;
      PropertyDescriptor pd = getPropertyDescriptor(cls, property);
      if (pd == null) {
      System.out.println("ERROR: Can't find " + property + " PropertyDescriptor for " + cls.getName());
      result = false;
      } else {
      System.out.println(property + " PropertyDescriptor found for " + cls.getName());
      }
      return result;
          }

          /**
           * Returns the property desriptor of a class for a property
           *
           * @param type The type of class
           * @param propertyName name of the propertie. i.e., "text" for get/setText()
           * @return the PropertyDescriptor or null
           */
          public static PropertyDescriptor getPropertyDescriptor(Class type,
      String propertyName) {
              BeanInfo info = getBeanInfo(type);
              PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors();
              for(int i = 0; i < propertyDescriptors.length; i++) {
                  PropertyDescriptor pd = propertyDescriptors[i];
                  if (propertyName.equals(pd.getName())) {
                      return pd;
                  }
              }
              return null;
          }

          /**
           * Retrieves the BeanInfo for a Class
           * Uses the new BeanInfo caching in the 1.4 Introspector.
           */
          public static BeanInfo getBeanInfo(Class cls) {
              BeanInfo beanInfo = null;
      try {
      beanInfo = Introspector.getBeanInfo(cls);
      } catch (IntrospectionException ex) {
      ex.printStackTrace();
      }
      return beanInfo;
          }

      }
      --------------------

      281 [cerebus] temp %java -showversion Focusable
      java version "1.4.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b90)
      Java HotSpot(TM) Client VM (build 1.4.0-rc-b90, mixed mode)

      ERROR: Can't find focusable PropertyDescriptor for java.awt.Component
      ERROR: Can't find focusable PropertyDescriptor for java.awt.Container
      ERROR: Can't find focusable PropertyDescriptor for javax.swing.JComponent
      ERROR: Can't find focusable PropertyDescriptor for javax.swing.AbstractButton
      ERROR: Can't find focusable PropertyDescriptor for javax.swing.JButton
      ERROR: Can't find focusable PropertyDescriptor for javax.swing.JToggleButton
      enabled PropertyDescriptor found for java.awt.Component
      enabled PropertyDescriptor found for java.awt.Container
      enabled PropertyDescriptor found for javax.swing.JComponent
      enabled PropertyDescriptor found for javax.swing.AbstractButton
      enabled PropertyDescriptor found for javax.swing.JButton
      enabled PropertyDescriptor found for javax.swing.JToggleButton
      name PropertyDescriptor found for java.awt.Component
      name PropertyDescriptor found for java.awt.Container
      name PropertyDescriptor found for javax.swing.JComponent
      name PropertyDescriptor found for javax.swing.AbstractButton
      name PropertyDescriptor found for javax.swing.JButton
      name PropertyDescriptor found for javax.swing.JToggleButton



            mdavidsosunw Mark Davidson (Inactive)
            mdavidsosunw Mark Davidson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: