robot.html
来自「API資料大全」· HTML 代码 · 共 541 行 · 第 1/2 页
HTML
541 行
<TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="Robot()"><!-- --></A><H3>Robot</H3><PRE>public <B>Robot</B>() throws <A HREF="../../java/awt/AWTException.html">AWTException</A></PRE><DL><DD>Constructs a Robot object in the coordinate system of the primary screen. <p><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/awt/AWTException.html">AWTException</A></CODE> - if the platform configuration does not allow low-level input control<DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if <code>createRobot</code> permission is not granted<DT><B>See Also: </B><DD><A HREF="../../java/lang/SecurityManager.html#checkPermission(java.security.Permission)"><CODE>SecurityManager.checkPermission(java.security.Permission)</CODE></A>, <A HREF="../../java/awt/AWTPermission.html"><CODE>AWTPermission</CODE></A></DL></DD></DL><HR><A NAME="Robot(java.awt.GraphicsDevice)"><!-- --></A><H3>Robot</H3><PRE>public <B>Robot</B>(<A HREF="../../java/awt/GraphicsDevice.html">GraphicsDevice</A> screen) throws <A HREF="../../java/awt/AWTException.html">AWTException</A></PRE><DL><DD>Creates a Robot for the given screen device. Coordinates passed to Robot method calls like mouseMove and createScreenCapture will be interpreted as being in the same coordinate system as the specified screen. Note that depending on the platform configuration, multiple screens may either: <ul> <li>share the same coordinate system to form a combined virtual screen</li> <li>use different coordinate systems to act as independent screens</li> </ul> This constructor is meant for the latter case. <p> If screen devices are reconfigured such that the coordinate system is affected, the behavior of existing Robot objects is undefined.<DD><DL><DT><B>Parameters:</B><DD><CODE>screen</CODE> - A screen GraphicsDevice indicating the coordinate system the Robot will operate in.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/awt/AWTException.html">AWTException</A></CODE> - if the platform configuration does not allow low-level input control<DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>screen</code> is not a screen GraphicsDevice.<DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if <code>createRobot</code> permission is not granted<DT><B>See Also: </B><DD><A HREF="../../java/awt/GraphicsDevice.html"><CODE>GraphicsDevice</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkPermission(java.security.Permission)"><CODE>SecurityManager.checkPermission(java.security.Permission)</CODE></A>, <A HREF="../../java/awt/AWTPermission.html"><CODE>AWTPermission</CODE></A></DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="mouseMove(int, int)"><!-- --></A><H3>mouseMove</H3><PRE>public void <B>mouseMove</B>(int x, int y)</PRE><DL><DD>Moves mouse pointer to given screen coordinates.<DD><DL><DT><B>Parameters:</B><DD><CODE>x</CODE> - X position<DD><CODE>y</CODE> - Y position</DL></DD></DL><HR><A NAME="mousePress(int)"><!-- --></A><H3>mousePress</H3><PRE>public void <B>mousePress</B>(int buttons)</PRE><DL><DD>Presses one or more mouse buttons.<DD><DL><DT><B>Parameters:</B><DD><CODE>buttons</CODE> - Button mask (combination of <code>InputEvent.BUTTON1/2/3_MASK</code>)<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the button mask is not a valid combination</DL></DD></DL><HR><A NAME="mouseRelease(int)"><!-- --></A><H3>mouseRelease</H3><PRE>public void <B>mouseRelease</B>(int buttons)</PRE><DL><DD>Releases one or more mouse buttons.<DD><DL><DT><B>Parameters:</B><DD><CODE>buttons</CODE> - Button mask (combination of <code>InputEvent.BUTTON1/2/3_MASK</code>)<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the button mask is not a valid combination</DL></DD></DL><HR><A NAME="keyPress(int)"><!-- --></A><H3>keyPress</H3><PRE>public void <B>keyPress</B>(int keycode)</PRE><DL><DD>Presses a given key. <p> Key codes that have more than one physical key associated with them (e.g. <code>KeyEvent.VK_SHIFT</code> could mean either the left or right shift key) will map to the left key.<DD><DL><DT><B>Parameters:</B><DD><CODE>keyCode</CODE> - Key to press (e.g. <code>KeyEvent.VK_A</code>)<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>keycode</code> is not a valid key</DL></DD></DL><HR><A NAME="keyRelease(int)"><!-- --></A><H3>keyRelease</H3><PRE>public void <B>keyRelease</B>(int keycode)</PRE><DL><DD>Releases a given key. <p> Key codes that have more than one physical key associated with them (e.g. <code>KeyEvent.VK_SHIFT</code> could mean either the left or right shift key) will map to the left key.<DD><DL><DT><B>Parameters:</B><DD><CODE>keyCode</CODE> - Key to release (e.g. <code>KeyEvent.VK_A</code>)<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>keycode</code> is not a valid key</DL></DD></DL><HR><A NAME="getPixelColor(int, int)"><!-- --></A><H3>getPixelColor</H3><PRE>public <A HREF="../../java/awt/Color.html">Color</A> <B>getPixelColor</B>(int x, int y)</PRE><DL><DD>Returns the color of a pixel at the given screen coordinates.<DD><DL><DT><B>Parameters:</B><DD><CODE>x</CODE> - X position of pixel<DD><CODE>y</CODE> - Y position of pixel<DT><B>Returns:</B><DD>Color of the pixel</DL></DD></DL><HR><A NAME="createScreenCapture(java.awt.Rectangle)"><!-- --></A><H3>createScreenCapture</H3><PRE>public <A HREF="../../java/awt/image/BufferedImage.html">BufferedImage</A> <B>createScreenCapture</B>(<A HREF="../../java/awt/Rectangle.html">Rectangle</A> screenRect)</PRE><DL><DD>Creates an image containing pixels read from the screen.<DD><DL><DT><B>Parameters:</B><DD><CODE>screenRect</CODE> - Rect to capture in screen coordinates<DT><B>Returns:</B><DD>The captured image<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>screenRect</code> width and height are not greater than zero<DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if <code>readDisplayPixels</code> permission is not granted<DT><B>See Also: </B><DD><A HREF="../../java/lang/SecurityManager.html#checkPermission(java.security.Permission)"><CODE>SecurityManager.checkPermission(java.security.Permission)</CODE></A>, <A HREF="../../java/awt/AWTPermission.html"><CODE>AWTPermission</CODE></A></DL></DD></DL><HR><A NAME="isAutoWaitForIdle()"><!-- --></A><H3>isAutoWaitForIdle</H3><PRE>public boolean <B>isAutoWaitForIdle</B>()</PRE><DL><DD>Returns whether this Robot automatically invokes <code>waitForIdle</code> after generating an event.<DD><DL><DT><B>Returns:</B><DD>Whether <code>waitForIdle</code> is automatically called</DL></DD></DL><HR><A NAME="setAutoWaitForIdle(boolean)"><!-- --></A><H3>setAutoWaitForIdle</H3><PRE>public void <B>setAutoWaitForIdle</B>(boolean isOn)</PRE><DL><DD>Sets whether this Robot automatically invokes <code>waitForIdle</code> after generating an event.<DD><DL><DT><B>Parameters:</B><DD><CODE>isOn</CODE> - Whether <code>waitForIdle</code> is automatically invoked</DL></DD></DL><HR><A NAME="getAutoDelay()"><!-- --></A><H3>getAutoDelay</H3><PRE>public int <B>getAutoDelay</B>()</PRE><DL><DD>Returns the number of milliseconds this Robot sleeps after generating an event.</DL><HR><A NAME="setAutoDelay(int)"><!-- --></A><H3>setAutoDelay</H3><PRE>public void <B>setAutoDelay</B>(int ms)</PRE><DL><DD>Sets the number of milliseconds this Robot sleeps after generating an event.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - If <code>ms</code> is not between 0 and 60,000 milliseconds inclusive</DL></DD></DL><HR><A NAME="delay(int)"><!-- --></A><H3>delay</H3><PRE>public void <B>delay</B>(int ms)</PRE><DL><DD>Sleeps for the specified time.<DD><DL><DT><B>Parameters:</B><DD><CODE>ms</CODE> - Time to sleep in milliseconds<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - If <code>ms</code> is not between 0 and 60,000 milliseconds inclusive</DL></DD></DL><HR><A NAME="waitForIdle()"><!-- --></A><H3>waitForIdle</H3><PRE>public void <B>waitForIdle</B>()</PRE><DL><DD>Waits until all events currently on the event queue have been processed.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalThreadStateException.html">IllegalThreadStateException</A></CODE> - if called on the AWT event dispatching thread</DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toString</B>()</PRE><DL><DD>Returns a string representation of this Robot.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the string representation.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Robot.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/awt/RenderingHints.Key.html"><B>PREV CLASS</B></A> <A HREF="../../java/awt/Scrollbar.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="Robot.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?