Java Swing Tutorial - Java Robot.waitForIdle()








Syntax

Robot.waitForIdle() has the following syntax.

public void waitForIdle()

Example

In the following code shows how to use Robot.waitForIdle() method.

/* ww  w.  ja  v  a  2  s.  c om*/
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class Main {
  public static void main(String[] argv) throws Exception {

    Robot robot = new Robot();

    robot.keyPress(KeyEvent.VK_A);
    robot.waitForIdle();
    robot.keyRelease(KeyEvent.VK_A);

  }
}