Class Record

java.lang.Object
  |
  +--Record
All Implemented Interfaces:
java.awt.event.AWTEventListener, java.util.EventListener, java.lang.Runnable

public final class Record
extends java.lang.Object
implements java.awt.event.AWTEventListener, java.lang.Runnable

Records keyboard events in a class that can be replayed later.

Mouse events are not handled for various reasons. The justification is that mouse clicks on the windows title bar don't get reported (so handling these requires clumsy logic involving window events as well), and involve factors outside my control such as double-click speed and screen size. The real reason is that I encountered a lot of repaint problems when mouse clicks occurred that did not arise with keyboard input. As I strongly believe in providing keyboard short-cuts for all actions anyway this ommission does not cause me any problems.

I have chosen to capture the results in a java program, which must be compiled, rather than in a script that could be parsed and executed, becuase I find it convenient to be able to manually edit the results. For example, it is trivial to add loops around certain sections of the script.

To execute:

  • java Record
  • javac Playback
  • java Playbakc
  • This class requires Java 1.3 becuase it uses the Robot and the AWTEventListener.


    Method Summary
     void eventDispatched(java.awt.AWTEvent ev)
              Records keyboard events to Playback,java.
    static void main(java.lang.String[] args)
              Runs the specified swing program and captures keyboard input events in a replayable java class.
     void run()
              Called on shutdown to close the output.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Method Detail

    main

    public static void main(java.lang.String[] args)
                     throws java.lang.Exception
    Runs the specified swing program and captures keyboard input events in a replayable java class.

    eventDispatched

    public void eventDispatched(java.awt.AWTEvent ev)
    Records keyboard events to Playback,java. Consumes mouse events to stop the tester from using them and messing up the script. Note that keyboard events may be thrown against more than one component - only the first occurrence is recorded.
    Specified by:
    eventDispatched in interface java.awt.event.AWTEventListener

    run

    public void run()
    Called on shutdown to close the output.
    Specified by:
    run in interface java.lang.Runnable