Like a monkey, Monkey "swings" through the UI trees in a particular Java 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.
The Monkey class is in the examples/Monkey directory included with this release of Java Accessibility (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 (e.g., jaccess-0.5/jaccess.jar or jaccess-0.5\jaccess.jar) file that comes with this prerelease kit is included in the path. Modify your CLASSPATH environment variable so that the Monkey directory (e.g., jaccess-0.5/examples/Monkey or jaccess-0.5\examples\Monkey) is included in the path. Modify your $JDKHOME/lib/awt.properties file (e.g., jdk1.1.2/lib/awt.properties or C:\jdk1.1.2\lib\awt.properties) to include the following lines (a sample awt.properties can be found here): AWT.EventQueueClass=com.sun.java.accessibility.EventQueueMonitor AWT.AutoLoadClasses=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.EventQueueMonitor: java.lang.ClassNotFoundException: com.sun.java.accessibility.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.
By following the instructions above, Monkey will automatically be started any time you start a Java application in a virtual machine. For example, if you run the "SwingSet" demonstration application that comes with the prerelease of the JFC (swing-0.5), Monkey will automatically start.
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.
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.
NOTE: This is a preliminary release of Java Accessibility. We reserve the right to modify the specification in future versions.