Skip to Main Content
Java Swing, 2nd Edition
book

Java Swing, 2nd Edition

by Dave Wood, Robert Eckstein, Marc Loy, James Elliott, Brian Cole
November 2002
Intermediate to advanced content levelIntermediate to advanced
1278 pages
38h 26m
English
O'Reilly Media, Inc.
Content preview from Java Swing, 2nd Edition

Interfacing with Accessibility

The following code shows how to create a simple assistive technology that can monitor events on the system event queue and interface with accessible components. The example consists of one class, AssistiveExample. This class creates a small window containing two labels and five checkboxes, which are repeatedly updated when the mouse comes to rest over an accessible component for longer than half a second.

Note that while using 1.2 or higher accessibility, we have to check to see if the GUI is ready for us to start firing accessibility-related commands. We do this by checking the EventQueueMonitor.isGUIInitialized( ) method. This method returns a boolean indicating whether the GUI will accept accessibility commands. If it does, then we’re fine. If it doesn’t, then we must register ourselves to be notified when the GUI becomes available. This uses the GUIInitializedListener interface, which we explained earlier.

To use the AssistiveExample class, simply create a new AssistiveExample object from an existing application. The constructor creates a frame and makes it visible. For an example, check the source of the BigExample class in the online code files for this chapter.

Finally, note that we have a single button in our assistive example that performs the first action reported by the accessible context. You can use the Tab key to bring this button into focus while pointing with the mouse, then press the space bar to fire the action.

// AssistiveExample.java ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Threads, 3rd Edition

Java Threads, 3rd Edition

Scott Oaks, Henry Wong

Publisher Resources

ISBN: 0596004087Errata PageSupplemental Content