The Source for Java - java.sun.com
JAVA ACCESSIBILITY UTILITIES
The Utility Classes
Version 1.3

[Home] [What is it?] [Overview of Features] [API Reference]
[FAQ] [Examples] [Changes] [Compatibility table] [JFC Home Page]


Explanation of the Java Accessibility Utilities 

The Java Accessibility Utilities are delivered by Sun as a separately downloadable package for use by assistive technology vendors in their products which provide access to Java applications running in a Java Virtual Machine. This package provides the necessary support for assistive technologies to locate and query user interface objects inside a Java application running in a Java Virtual Machine. It also provides support for installing "event listeners" into these objects. These event listeners allow objects to learn about specific evens occurring in other objects using the peer-to-peer approach defined by the delegation event model introduced in JDK1.1.

This package is still in active development, and is not as fully defined as the Java Accessibility API. This package is made up of the following major pieces:

Key information about the Java Application(s)

This package contains methods for retrieving key information about the Java application(s) running in the Java Virtual Machine. This support provides a list of the top-level windows of all of the Java applications, an event listener architecture to be informed when top level windows appear (and disappear), and means for locating the window that has the input focus, locating the mouse position, and inserting events into the system event queue. In order to provide this support immediately for the JDK1.1 environments, Sun took advantage of an implementation detail in the Sun reference implementation of the JDK. In the Sun implementation, the system-wide EventQueue can be replaced with an alternate one. The Java Accessibility Utilities provide an alternate system EventQueue in the class EventQueueMonitor that implements the functionality described previously.

Automatic Loading of Assistive Technologies

In order for an assistive technology to work with a Java application, it needs to be loaded into the same Java Virtual Machine as the Java application it is providing access to. This is done by extending the class libraries to look for a special configuration line in the awt.properties file specifying a list of assistive technology classes to load. This support is in the class EventQueueMonitor, which is a replacement for the system event queue.  As stated above, the EventQueueMonitor implementation is dependent upon specific details of the Sun reference implementation of the JDK1.1 Java Virtual Machine, and not on the formal specification. Because of this, automatic loading of assistive technologies may not work in all JDK1.1 environments.  The automatic loading of assistive technologies is part of the JDK1.2 specification, however, so this support will be in all Java Virtual Machines that support JDK1.2.

Event Support

The Java Accessibility Utilities include three classes for monitoring events in the Java Virtual Machine. The first class, AWTEventMonitor, provides a way to monitor all AWT events in all AWT components running in the Java Virtual Machine. This class essentially provides system-wide monitoring of AWT events, registering an individual listener for each AWT event type on each AWT component that supports that type of listener. Thus, an assistive technology can register a "Focused listener" with AWTEventMonitor, which will in turn register a "Focused listener" with each and every AWT component in each and every Java application in the Java Virtual Machine. Those individual listeners will funnel the events they hear about to the assistive technology that registered the listener with AWTEventMonitor in the first place. Thus, whenever a component gains or loses focus (e.g. the user hits the TAB key), the assistive technology will be notified.

The second class, SwingEventMonitor, extends AWTEventMonitor to provide additional support for monitoring the Swing events supported by the Swing components.  Since SwingEventMonitor extends AWTEventMonitor, there is no need to use both classes if you are using SwingEventMonitor in your assistive technology.

The third class, AccessibilityEventMonitor, provides support for property change events on Accessible objects.  When an assisitive technology requests notification of Accessible property change events using AccessibilityEventMonitor, the AccessibilityEventMonitor will automatically register Accessible property change listeners on all the components.  In addition, it will detect when components are added and removed from the component hierarchy and add and remove the property change listeners accordingly.  When an Accessible property change occurs in any of the components, the AccessibilityEventMonitor will notify the assistive technology.

AWT Translators

With the release of the Java Foundation Classes (JFC), many developers who were using the AWT to build the user interfaces of their Java applications will switch to the new Swing classes in the JFC. Many will also update their existing AWT programs to Swing. Still, a significant number of Java applications will remain using some AWT components for displaying their user interfaces. The Java Accessibility Utilities contain a set of classes which implement the Java Accessibility API on behalf of AWT components -- in effect translating for them!  These translators work in concert with the support for finding Accessible components in the first place, which is part of the EventQueueMonitor method getAccessibleAt.  If the object at that location isn't an actual instance of an Accessible, the getAccessibleAt method looks for a Translator that will implement the Accessible interface on behalf of that component.

Like much of the rest of the Java Accessibility support, the translator architecture is completely extensible. Any programmer can create a translator. As long as the user's environment is configured properly, the Java Accessibility utility classes will automatically find the new translator and engage it. This means that both mainstream developers and assistive technology vendors can create and distribute new Accessible Translators, making formerly inaccessible user interface components accessible in the process.

Sample Source Code

In addition to the utility classes and translator architecture, the Java Accessibility Utilties includes several example assistive technology programs. The example programs include programs that monitor AWT and Swing events, a program that fully exercises the Java Accessibility API for the component underneath the mouse, and a program that traverses the component hierarchy, displaying the entire hierarchy in tree view.