1 /* 2 * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.awt.peer; 27 28 import java.awt.*; 29 30 /** 31 * RobotPeer defines an interface whereby toolkits support automated testing 32 * by allowing native input events to be generated from Java code. 33 * 34 * This interface should not be directly imported by code outside the 35 * java.awt.* hierarchy; it is not to be considered public and is subject 36 * to change. 37 * 38 * @author Robi Khan 39 */ 40 public interface RobotPeer 41 { 42 /** 43 * Moves the mouse pointer to the specified screen location. 44 * 45 * @param x the X location on screen 46 * @param y the Y location on screen 47 * 48 * @see Robot#mouseMove(int, int) 49 */ 50 void mouseMove(int x, int y); 51 52 /** 53 * Simulates a mouse press with the specified button(s). 54 * 55 * @param buttons the button mask 56 * 57 * @see Robot#mousePress(int) 58 */ 59 void mousePress(int buttons); 60 61 /** 62 * Simulates a mouse release with the specified button(s). 63 * 64 * @param buttons the button mask 65 * 66 * @see Robot#mouseRelease(int) 67 */ 68 void mouseRelease(int buttons); 69 70 /** 71 * Simulates mouse wheel action. 72 * 73 * @param wheelAmt number of notches to move the mouse wheel 74 * 75 * @see Robot#mouseWheel(int) 76 */ 77 void mouseWheel(int wheelAmt); 78 79 /** 80 * Simulates a key press of the specified key. 81 * 82 * @param keycode the key code to press 83 * 84 * @see Robot#keyPress(int) 85 */ 86 void keyPress(int keycode); 87 88 /** 89 * Simulates a key release of the specified key. 90 * 91 * @param keycode the key code to release 92 * 93 * @see Robot#keyRelease(int) 94 */ 95 void keyRelease(int keycode); 96 97 /** 98 * Gets the RGB value of the specified pixel on screen. 99 * 100 * @param x the X screen coordinate 101 * @param y the Y screen coordinate 102 * 103 * @return the RGB value of the specified pixel on screen 104 * 105 * @see Robot#getPixelColor(int, int) 106 */ 107 int getRGBPixel(int x, int y); 108 109 /** 110 * Gets the RGB values of the specified screen area as an array. 111 * 112 * @param bounds the screen area to capture the RGB values from 113 * 114 * @return the RGB values of the specified screen area 115 * 116 * @see Robot#createScreenCapture(Rectangle) 117 */ 118 int[] getRGBPixels(Rectangle bounds); 119 120 /** 121 * Disposes the robot peer when it is not needed anymore. 122 */ 123 void dispose(); 124 }