473,432 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,432 software developers and data experts.

java.awt.Robot - Stimulate Key Press Not Working

17
Dear All,

I had google for example how to use java.awt.Robot class. I also read Java Document regarding of awt.Robot class. When I test below code, I get error message "cannot find symbol method delay(int)" and "cannot find symbol method keyPress (int)". May I know what is my problem?

*Installed JDK Version 6 update 21

Expand|Select|Wrap|Line Numbers
  1. import java.awt.AWTException;
  2. import java.awt.Robot;
  3. import java.awt.event.KeyEvent;
  4.  
  5. public class MyRobot
  6. {
  7.     public static void main (String [] args)
  8.     {
  9.         try {
  10.             MyRobot myrobot = new MyRobot();
  11.  
  12.             myrobot.delay(3000);
  13.             myrobot.keyPress(KeyEvent.VK_T);
  14.             myrobot.keyPress(KeyEvent.VK_E);
  15.             myrobot.keyPress(KeyEvent.VK_S);
  16.             myrobot.keyPress(KeyEvent.VK_K);
  17.  
  18.         } catch (AWTException e) {
  19.             e.printStackTrace();
  20.         }
  21.     }
  22. }
Sep 23 '10 #1
2 6680
try

Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.event.*;
  3.  
And

Expand|Select|Wrap|Line Numbers
  1. Robot myrobot = new Robot();
  2.  
Sep 27 '10 #2
xirowei
17
Dear Ian Smith,

I try your solution and it works! The main issue in my code is:

//Incorrect code
MyRobot myrobot = new MyRobot();

//Correct code
Robot myrobot = new Robot();
Oct 3 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: River | last post by:
i just started a Java class, the PC's in school have w2000, at home i have XP Home. when i try to compile in DOS using javac it doesnt work. i can't seem to find a solution to this problem. i would...
73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
458
by: wellstone9912 | last post by:
Java programmers seem to always be whining about how confusing and overly complex C++ appears to them. I would like to introduce an explanation for this. Is it possible that Java programmers...
0
by: Tomek | last post by:
Welcome. I`m trying to prepere some project that shows how to use Corba technology i heterogenic systems.I`d like to create CORBA server with Borland Delphi (or C#.NET) and few client...
0
by: balaji krishna | last post by:
Hi, I need to handle the return set from COBOL stored procedure from my invoking Java program. I do not know, how many rows the stored proc SQL fetches.I have declared the cursor in that proc, but i...
5
by: CoolForU | last post by:
this is my code and i call this code from code behinde file on page load like this useragree.Attributes.Add("onclick", "CheckSelection();") this is working fine with IE but not working with...
3
by: mystikwhitewolf | last post by:
I have Windows 98SE(yes I know horribly old) and my Java applet has quit working. I've tried re-installing from Java.com but I just get a blank screen if I try to load a Pogo or Yahoo game. I then...
7
by: bnashenas1984 | last post by:
Hi everyone Actually I'm a php programer and don't no so much about java. After searching on google I found the java code you see below to open a popup when user moves the mouse pointer over a link....
20
by: mc | last post by:
I may be opening a can of worms and don't want to start a religious war, but... What features of Java do Java programmers miss when working in C#? Other than, of course, great portability. C#...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.