View RSS Feed

Java AWT

Java Abstract Window Toolkit (AWT)

  1. How to use Robot class in Java?

    by , 03-04-2012 at 10:43 AM
    For controlling the keyboard or mouse, class java.awt.Robot will be used. Any kind of operation regarding mouse or keyboard can be performed once one has the control over mouse & keyboard. Usually such class type is used while doing test automation.

    Robot class which handles the keyboard events will be shown up by using this code. If this code is run, a notepad will be opened to write down “HI MY FRIEND”.
    Java Code:
    import java.awt.AWTException; 
    import java.awt.Robot;