Use of Robot Class

Use of Robot Class

Programming in Java doesn’t have to be dull and boring. In fact, it’s possible to have lots of fun while programming in Java. Lets use the Robot class to write programs that are both fun and useful.
Added in JDK v 1.3 .
As Per Sun (now Oracle):
“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.”
Lets Start the fun by Moving Mouse Pointer Programmatically.

Ex 2: Right Click of Mouse

Lets Play With Keyboard Events
This sample code will show the use of Robot class to handle the keyboard events. If you run this code and open a notepad then this code will write hi budy in the notepad.

Now you have enough input to start playing with Robot Class, just google for more and have fun.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.