How can I duplicate an Event in one GUI on another identical GUI? (e.g. Press a button on one GUI shows the button pressing on the other)

Chuk Yeung

You can use the Robot class (java.awt.Robot) to mimic most key and mouse events. Once an event has been received by the first GUI, the Robot can be used to duplicate the event on the second GUI. This is assuming of course that the GUIs are part of the same program.

If the mimicing you want to do just involves button presses and filling in text areas, you may want to use a brute force method: make direct calls to the targeted button(s) and/or text components using the doClick(int pressTime) and setText(String t) methods respectively.

[FAQ Manager Note] This only works with later versions of the Java runtime environment. Robot is in v1.3, and doClick() only works in v1.2 and later.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact