|
Size: 804
Comment:
|
Size: 908
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 6: | Line 6: |
| == Sample code == | == Robot.java == |
| Line 37: | Line 37: |
To run the code {{{#!highlight sh java Robot.java # Press CTRL+C to stop and exit the program }}} |
Robot
The primary purpose of Robot is to facilitate automated testing of Java platform implementations.
Robot.java
1 import java.awt.Robot;
2
3 public class Main{
4 public static int DELAY=10000;
5 public static int MOVE=100;
6 private static Robot robot;
7
8 public static void main(String[] args){
9 try{
10 System.out.println("Hello");
11 robot=new Robot();
12 while(true){
13 move(0,0);
14 move(MOVE,0);
15 move(MOVE,MOVE);
16 move(0,MOVE);
17 }
18 }
19 catch(Exception ex){
20 ex.printStackTrace();
21 }
22 }
23
24 public static void move(int x,int y){
25 robot.mouseMove(x,y);
26 robot.delay(DELAY);
27 }
28 }
To run the code
