The Source for Java - java.sun.com
JAVA ACCESSIBILITY
Java Accessibility Monkey Example
Version 1.3

[Home] [What are they?] [Overview of API Features] [API Reference]
[FAQ] [Examples] [Changes] [Compatibility table] [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.

Snap shot of Monkey in action.

Preparing to Run Monkey with JDK1.1:

The Monkey class is in the examples/Monkey directory included with this release of the Java Accessibility Utilities (click here to view the source). The compiled classes of Monkey are also included in the jaccess-examples.jar file includes with this release.  Before you can run Monkey, you need to set up your environment appropriately by following these instructions:

  • Add the jaccess.jar and jaccess-examples.jar files to your CLASSPATH environment variable.
  • Modify your $JDKHOME/lib/awt.properties file to include the following lines:
  • 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 JavaTM 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 the jaccess.jar file is not in your CLASSPATH, and the second means the jaccess-examples.jar file is not in your CLASSPATH.

    Preparing to Run Monkey with JDK1.2 or later:

    To run Monkey with JDK1.2 or later you need to have obtained and installed JDK1.2 or later. In addition, you need to be using the Java Accessibility Utilities Version 1.2 or later.

    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:

  • Copy jaccess.jar and jaccess-examples.jar to the $JDKHOME/jre/lib/ext directory under your JDK1.2 or later installation.
  • Modify (create one if it doesn't exist) your $JDKHOME/jre/lib/accessibility.properties file to include the following line:
  • assistive_technologies=Monkey
    After you follow these instructions, you should be ready to run Monkey.

    Running Monkey with JDK1.1, JDK1.2 or later:

    By following the instructions above, Monkey will automatically be started any time you start a Java application. For example, you can run the SwingSet demo that comes as part of the demonstration applications for Swing.

    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, the third option allows you to manipulate the AccessibleSelections of the object, and the fourth option allows you to manipulate the AccessibleHypertext links of the object. You can bring up an AccessibilityPanel without using the mouse by first selecting the table cell you are interested in, and then choosing the AccessibilityPanel from the Panels menu.
    Picture of the panel that allows you to manipulate the object's AccessibleActionsPicture of the panel that allows you to manipulate the object's AccessibleSelectionPicture of the panel that allows you to manipu late the object's AccessibleHypertext

    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.  At any time, you can press the F1 key and Monkey will automatically refresh the trees as well.


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

    Sun MicroSystems