The Artima Developer Community
Sponsored Link

Legacy Design Forum
Event Generator Idiom



This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


how to fake an event

Posted by Dima on November 29, 2001 at 9:07 PM

If you are using swing, you can just extend the class JLabel (or ToolTipManager - I'm not sure, but you can look in the source) and call processMouseMotionEvent when you need to - everything is usually done there. Swing is written completely in java, without any peers, so you can make it do anything.

There is also a very nice class Robot in java.awt. You can just write

Robot r = new Robot ();
r.mouseMove (x, y);

and it will actually move the mouse anywhere you want. You can click, press any keys, get the image from the screen. (You can make it press Ctrl-C, and the program will be stopped; Alt+Ctrl+Del, and it will show the Close Program dialog, if you are using Windows).
But in your case you, probably, don't want the mouse pointer to move. And if it's an applet, the web browser probably won't let your program do any of this stuff.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us