Java Reference
In-Depth Information
// With description argument
public ImageIcon(Image image, String description)
public ImageIcon(String filename, String description)
public ImageIcon(URL location, String description)
public ImageIcon(byte imageData[], String description)
By creating an ImageIcon with a description, your program automatically becomes more
accessible. In addition to creating the icon with a description argument to the constructor,
you can also assign the text later by calling the setDescription() method.
One important interface, Accessible , and an abstract class, AccessibleContext , provide
the core framework for the Java Accessibility API.
Accessible Interface
For a Swing component to work within the accessibility framework, it must implement the
Accessible interface.
public interface Accessible {
// Property
public AccessibleContext getAccessibleContext();
}
As the interface definition shows, there is only one method, which gets the current
AccessibleContext instance for the implementing class. All the standard AWT and Swing
components implement the interface. Several internal aspects of components, like the system
menu bar on the title pane of the JInternalFrame , also implement the Accessible interface.
AccessibleContext Class
While the Accessible interface is all that a component must implement, the work is actually done
in the AccessibleContext instance that it returns. The returned context is practically another
component. It maps the accessible properties to the properties of the component. For example,
with the JLabel component, when you get its AccessibleContext , you are getting the concrete
subclass known as AccessibleJLabel . This subclass maps JLabel properties, such as the accessi-
bleName property to the text property. As shown in Table 22-1, the abstract class itself is larger than
the interface.
Table 22-1. AccessibleContext Properties
Property Name
Data Type
Access
accessibleAction
AccessibleAction
Read-only
accessibleChildrenCount
int
Read-only
accessibleComponent
AccessibleComponent
Read-only
accessibleDescription
String
Read-write bound
accessibleEditableText
AccessibleEditableText
Read-only
 
Search WWH ::




Custom Search