java.awt

Class Robot

  • java.lang.Object
    • java.awt.Robot
  • public class Robot extends java.lang.Object
    This class is used to generate native system input events for the purposes of test automation, self-running demos, and other applications where control of the mouse and keyboard is needed. The primary purpose of Robot is to facilitate automated testing of Java platform implementations.

    Using the class to generate input events differs from posting events to the AWT event queue or AWT components in that the events are generated in the platform's native input queue. For example, Robot.mouseMove will actually move the mouse cursor instead of just generating mouse move events.

    Note that some platforms require special privileges or extensions to access low-level input control. If the current platform configuration does not allow input control, an AWTException will be thrown when trying to construct Robot objects. For example, X-Window systems will throw the exception if the XTEST 2.2 standard extension is not supported (or not enabled) by the X server.

    Applications that use Robot for purposes other than self-testing should handle these error conditions gracefully.

    Since:
    1.3
    • Constructors 
      Constructor and Description
      Ordinary member indicator Robot Reveal DetailHide Detail
      Constructs a Robot object in the coordinate system of the primary screen.
      Ordinary member indicator Robot Reveal DetailHide Detail
      Creates a Robot for the given screen device.
    • Methods 
      Modifier and Type Method and Description
      Ordinary member indicator createScreenCapture Reveal DetailHide Detail
      Creates an image containing pixels read from the screen.
      Ordinary member indicator delay Reveal DetailHide Detail
      Sleeps for the specified time.
      Ordinary member indicator getAutoDelay Reveal DetailHide Detail
      Returns the number of milliseconds this Robot sleeps after generating an event.
      Ordinary member indicator getPixelColor Reveal DetailHide Detail
      Returns the color of a pixel at the given screen coordinates.
      Ordinary member indicator isAutoWaitForIdle Reveal DetailHide Detail
      Returns whether this Robot automatically invokes waitForIdle after generating an event.
      Ordinary member indicator keyPress Reveal DetailHide Detail
      Presses a given key.
      Ordinary member indicator keyRelease Reveal DetailHide Detail
      Releases a given key.
      Ordinary member indicator mouseMove Reveal DetailHide Detail
      Moves mouse pointer to given screen coordinates.
      Ordinary member indicator mousePress Reveal DetailHide Detail
      Presses one or more mouse buttons.
      Ordinary member indicator mouseRelease Reveal DetailHide Detail
      Releases one or more mouse buttons.
      Ordinary member indicator mouseWheel Reveal DetailHide Detail
      Rotates the scroll wheel on wheel-equipped mice.
      Ordinary member indicator setAutoDelay Reveal DetailHide Detail
      Sets the number of milliseconds this Robot sleeps after generating an event.
      Ordinary member indicator setAutoWaitForIdle Reveal DetailHide Detail
      Sets whether this Robot automatically invokes waitForIdle after generating an event.
      Overridden member indicator toString Reveal DetailHide Detail
      Returns a string representation of this Robot.
      Ordinary member indicator waitForIdle Reveal DetailHide Detail
      Waits until all events currently on the event queue have been processed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
This document was created by Dulcet from the OpenJDK sources. Copyright © 1993, 2012 Oracle and/or its affiliates. All rights reserved.

SourceForge