Java Doc for Robot.java in  » 6.0-JDK-Modules » j2me » sun » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » sun.awt 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   sun.awt.Robot

Robot
public class Robot (Code)
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.

Using the class to generate input events differs from posting events to the AWT event queue or AWT components in that the events are generated in the platform's native input queue. For example, Robot.mouseMove will actually move the mouse cursor instead of just generating mouse move events.

Note that some platforms require special privileges or extensions to access low-level input control. If the current platform configuration does not allow input control, an AWTException will be thrown when trying to construct Robot objects. For example, X-Window systems will throw the exception if the XTEST 2.2 standard extension is not supported (or not enabled) by the X server.

Applications that use Robot for purposes other than self-testing should handle these error conditions gracefully.
version:
   1.3, 11/21/02
author:
   Nicholas Allen




Constructor Summary
public  Robot()
     Constructs a Robot object in the coordinate system of the primary screen.


throws:
  AWTException - if the platform configuration does not allowlow-level input control.

public  Robot(GraphicsDevice screen)
     Creates a Robot for the given screen device.

Method Summary
public synchronized  BufferedImagecreateScreenCapture(Rectangle screenRect)
     Creates an image containing pixels read from the screen.
public synchronized  voiddelay(int ms)
     Sleeps for the specified time.
public synchronized  intgetAutoDelay()
     Returns the number of milliseconds this Robot sleeps after generating an event.
public synchronized  ColorgetPixelColor(int x, int y)
     Returns the color of a pixel at the given screen coordinates.
public synchronized  booleanisAutoWaitForIdle()
     Returns whether this Robot automatically invokes waitForIdle after generating an event.
public synchronized  voidkeyPress(int keycode)
     Presses a given key.

Key codes that have more than one physical key associated with them (e.g.

public synchronized  voidkeyRelease(int keycode)
     Releases a given key.

Key codes that have more than one physical key associated with them (e.g.

public synchronized  voidmouseMove(int x, int y)
     Moves mouse pointer to given screen coordinates.
public synchronized  voidmousePress(int buttons)
     Presses one or more mouse buttons.
public synchronized  voidmouseRelease(int buttons)
     Releases one or more mouse buttons.
public synchronized  voidsetAutoDelay(int ms)
     Sets the number of milliseconds this Robot sleeps after generating an event.
public synchronized  voidsetAutoWaitForIdle(boolean isOn)
     Sets whether this Robot automatically invokes waitForIdle after generating an event.
public synchronized  StringtoString()
     Returns a string representation of this Robot.
public synchronized  voidwaitForIdle()
     Waits until all events currently on the event queue have been processed.


Constructor Detail
Robot
public Robot() throws AWTException(Code)
Constructs a Robot object in the coordinate system of the primary screen.


throws:
  AWTException - if the platform configuration does not allowlow-level input control. This exception is always thrown whenGraphicsEnvironment.isHeadless() returns true
throws:
  SecurityException - if createRobot permission is not granted
See Also:   java.awt.GraphicsEnvironment.isHeadless
See Also:   SecurityManager.checkPermission
See Also:   AWTPermission




Robot
public Robot(GraphicsDevice screen) throws AWTException(Code)
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:
  • share the same coordinate system to form a combined virtual screen
  • use different coordinate systems to act as independent screens
This constructor is meant for the latter case.

If screen devices are reconfigured such that the coordinate system is affected, the behavior of existing Robot objects is undefined.
Parameters:
  screen - A screen GraphicsDevice indicating the coordinatesystem the Robot will operate in.
throws:
  AWTException - if the platform configuration does not allowlow-level input control. This exception is always thrown whenGraphicsEnvironment.isHeadless() returns true.
throws:
  IllegalArgumentException - if screen is not a screenGraphicsDevice.
throws:
  SecurityException - if createRobot permission is not granted
See Also:   java.awt.GraphicsEnvironment.isHeadless
See Also:   GraphicsDevice
See Also:   SecurityManager.checkPermission
See Also:   AWTPermission





Method Detail
createScreenCapture
public synchronized BufferedImage createScreenCapture(Rectangle screenRect)(Code)
Creates an image containing pixels read from the screen.
Parameters:
  screenRect - Rect to capture in screen coordinates The captured image
throws:
  IllegalArgumentException - if screenRect width and height are not greater than zero
throws:
  SecurityException - if readDisplayPixels permission is not granted
See Also:   SecurityManager.checkPermission
See Also:   AWTPermission



delay
public synchronized void delay(int ms)(Code)
Sleeps for the specified time. To catch any InterruptedExceptions that occur, Thread.sleep() may be used instead.
Parameters:
  ms - time to sleep in milliseconds
throws:
  IllegalArgumentException - if ms is not between 0 and 60,000 milliseconds inclusive
See Also:   java.lang.Thread.sleep



getAutoDelay
public synchronized int getAutoDelay()(Code)
Returns the number of milliseconds this Robot sleeps after generating an event.



getPixelColor
public synchronized Color getPixelColor(int x, int y)(Code)
Returns the color of a pixel at the given screen coordinates.
Parameters:
  x - X position of pixel
Parameters:
  y - Y position of pixel Color of the pixel



isAutoWaitForIdle
public synchronized boolean isAutoWaitForIdle()(Code)
Returns whether this Robot automatically invokes waitForIdle after generating an event. Whether waitForIdle is automatically called



keyPress
public synchronized void keyPress(int keycode)(Code)
Presses a given key.

Key codes that have more than one physical key associated with them (e.g. KeyEvent.VK_SHIFT could mean either the left or right shift key) will map to the left key.
Parameters:
  keyCode - Key to press (e.g. KeyEvent.VK_A)
throws:
  IllegalArgumentException - if keycode is not a valid key
See Also:   java.awt.event.KeyEvent




keyRelease
public synchronized void keyRelease(int keycode)(Code)
Releases a given key.

Key codes that have more than one physical key associated with them (e.g. KeyEvent.VK_SHIFT could mean either the left or right shift key) will map to the left key.
Parameters:
  keyCode - Key to release (e.g. KeyEvent.VK_A)
throws:
  IllegalArgumentException - if keycode is not a valid key
See Also:   java.awt.event.KeyEvent




mouseMove
public synchronized void mouseMove(int x, int y)(Code)
Moves mouse pointer to given screen coordinates.
Parameters:
  x - X position
Parameters:
  y - Y position



mousePress
public synchronized void mousePress(int buttons)(Code)
Presses one or more mouse buttons.
Parameters:
  buttons - the Button mask; a combination of one or moreof these flags:
  • InputEvent.BUTTON1_MASK
  • InputEvent.BUTTON2_MASK
  • InputEvent.BUTTON3_MASK

throws:
  IllegalArgumentException - if the button mask is not avalid combination



mouseRelease
public synchronized void mouseRelease(int buttons)(Code)
Releases one or more mouse buttons.
Parameters:
  buttons - the Button mask; a combination of one or moreof these flags:
  • InputEvent.BUTTON1_MASK
  • InputEvent.BUTTON2_MASK
  • InputEvent.BUTTON3_MASK

throws:
  IllegalArgumentException - if the button mask is not a validcombination



setAutoDelay
public synchronized void setAutoDelay(int ms)(Code)
Sets the number of milliseconds this Robot sleeps after generating an event.
throws:
  IllegalArgumentException - If ms is not between 0 and 60,000 milliseconds inclusive



setAutoWaitForIdle
public synchronized void setAutoWaitForIdle(boolean isOn)(Code)
Sets whether this Robot automatically invokes waitForIdle after generating an event.
Parameters:
  isOn - Whether waitForIdle is automatically invoked



toString
public synchronized String toString()(Code)
Returns a string representation of this Robot. the string representation.



waitForIdle
public synchronized void waitForIdle()(Code)
Waits until all events currently on the event queue have been processed.
throws:
  IllegalThreadStateException - if called on the AWT event dispatching thread



Methods inherited from java.lang.Object
public boolean equals(Object obj)(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.