Types of Accessibility

Accessible components can export several types of assistive functionalities—for example: actions, text properties, component properties, icon properties, selections, table properties, hypertext, and bounded-range value properties. Most of these functions are already present in the Swing components, so if you stick closely to Swing, you probably won’t need to implement these interfaces in your components. In an effort to explain how one might implement these interfaces, we have provided a simple example showing how to add AccessibleAction support to an AWT-based component.

The AccessibleAction Interface

The AccessibleAction interface outlines the methods that an accessible object or component must have to export its actions. The idea is that an assistive technology can determine the correct action by obtaining the total number of actions that the component exports, then reviewing each of their descriptions to resolve the correct one. Once this has occurred, the doAccessibleAction( ) method can be called with the correct index to invoke the required method.


The properties in Table 25-5 must be readable through the AccessibleAction interface. accessibleActionCount stores the number of accessible actions that the component implements. The indexed property accessibleActionDescription provides a string describing the action associated with the given index. The action with index 0 is the component’s default action.

Table 25-5. AccessibleAction properties ...

Get Java Swing, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.