The Source for Java - java.sun.com
JAVA ACCESSIBILITY
Java Accessibility Monkey Example
Version 1.0
March 1998

[Home] [What are they?] [Overview of API Features] [API Reference]
[FAQ] [Examples] [Changes] [JFC Home Page]

Like a monkey, Monkey "swings" through the component trees in a particular JavaTM Virtual Machine and presents the hierarchy in two different ways. The first is the actual Component hierarchy and the second is the hierarchy viewed as Accessible objects.  In addition, if the user clicks the right mouse button over a tree node in Monkey, Monkey will present the user with a popup menu containing options for manipulating the object.

To run Monkey you need to have obtained and installed the JDK 1.1.5 or better, and the Java Foundation Classes.

Snap shot of Monkey in action.

Preparing to Run Monkey:

The Monkey class is in the examples/Monkey directory included with this release of the Java Accessibility Utilities (click here to view the source). Before you can run it, you need to set up your environment appropriately by following these instructions:
  • Modify your CLASSPATH environment variable so that the jaccess.jar file that comes with this kit is included in the path.
  • Modify your CLASSPATH environment variable so that the examples/Monkey and examples/AccessibilityPanels directories that come with this kit are included in the path.
  • Modify your $JDKHOME/lib/awt.properties file (e.g., jdk1.1.5/lib/awt.properties or C:\jdk1.1.5\lib\awt.properties) to include the following lines (a sample awt.properties can be found here):
  • AWT.EventQueueClass=com.sun.java.accessibility.util.EventQueueMonitor
    AWT.assistive_technologies=Monkey
    After you follow these instructions, you should be ready to run Monkey. If you did not set up your CLASSPATH correctly you might get one of the following errors when running a Java application:
    Failed loading com.sun.java.accessibility.util.EventQueueMonitor: java.lang.ClassNotFoundException: com.sun.java.accessibility.util.EventQueueMonitor
    Error trying to newInstance Monkey java.lang.ClassNotFoundException: Monkey
    The first error means that the jaccess.jar file is not in your CLASSPATH, and the second that the Monkey directory is not in your CLASSPATH.

    Running Monkey:

    By following the instructions above, Monkey will automatically be started any time you start a Java application. For example, if you run the "SwingSet" demonstration application that comes with the prerelease of the Java Foundation Classes, Monkey will automatically start.

    Using Monkey:

    In its "File" menu, Monkey provides a "Refresh Trees" item. When you select this, Monkey will ask the EventQueueMonitor for the current list of top level windows it has detected in the virtual machine. It will then display the component hierarchy of the top level windows using two different formats. On the left side of its window, Monkey will display the "true" component hierarchy. On the right hand side of its window, Monkey will display the hierarchy as though the objects are Accessible objects.  If you right click on a node in the right hand side of its window, Monkey will display a popup menu that provides options for you to get additional accessible information from the object.  The first option will provide you with information similar to that provided by the Explorer example.  The second option allows you to manipulate the AccessibleActions of the object, and the third option allows you to manipulate the AccessibleSelections of the object.
    Picture of the panel that allows you to manipulate the object's AccessibleActions Picture of the panel that allows you to manipulate the object's AccessibleSelection

    Depending upon when it starts, the initial list displayed by Monkey may not accurately reflect the current state of the Java Virtual Machine. To update the display, select the "Refresh Trees" item in Monkey's "File" menu.


    Java Logo Copyright© 1995-97 Sun Microsystems, Inc. All Rights Reserved.
    To submit comments or suggestions about Java Accessibility, please send mail to access@sun.com.

    Sun MicroSystems