JDK-4619792 : Introspector cannot find the "focusable" property.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2002-01-05
  • Updated: 2002-04-27
  • Resolved: 2002-04-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.1 hopperFixed
Related Reports
Relates :  
Description
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




Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: hopper FIXED IN: hopper INTEGRATED IN: hopper
14-06-2004

PUBLIC COMMENTS .
10-06-2004

EVALUATION Once again, we are stymied by the existence of sun.beans.infos.ComponentBeanInfo as the default BeanInfo for Component. The getPropertyDescriptors() method has been overloaded return only 6 properties. There are probably a lot of properties which are not exposed. Should add the focusable property to this or eliminate this explicit BeanInfo all together. ###@###.### 2002-02-15
15-02-2002