How can I get the events from a java program?

I want to make a monitor to watch a java program.How can I get the events from the GUI of this program some as mouse cliking, keyinput. So I can watch these in my monitor.Thanks
[191 byte] By [Daniel5a] at [2007-10-2 2:06:03]
# 1

Hi,

To put a monitor to the events occuring in the GHUI u need to register required components with the appropriate EventListeners.

Liek if u want to get notified when a mouse is clicked, then u need to add The MouseListener to the component which u want to be monitored.

Say

myFrame which is the JFrame object which shuld be monitored for the events.

Then in ur program u have to add following code

myFrame.addMouseListener( someObectReference );

Here the someObjectReference should be an instance to a concrete class ..i.e. U write a class like the following

public class MyMouseListener implements MouseListener {

//override the followig methods

public void mouseClicked(MouseEvent me){ sop("MOUSE CLICKED ON THE FRAME");}

public void mousePressed(MouseEvent me){}

public void mouseReleased(MouseEvent me){}

....

...

...

}

If u dont want to use another class for listening to the events. Then u can make teh current class monitor the events. To do so ur class should implement the appropriate listener and should override the required methods.

and u should say myFrame.addMouseListenet( this );

thats it

vmaheshrajaa at 2007-7-15 19:47:28 > top of Java-index,Desktop,Core GUI APIs...
# 2
Use an AWTEventListener.
camickra at 2007-7-15 19:47:28 > top of Java-index,Desktop,Core GUI APIs...