Alright,
I have a JFrame which uses a classloader to load an Applet onto a JPanel, which is added to my JFrame.
The java Applet is a game in which I am trying to create a "bot" for. I would like to be able to minimize my JFrame and allow the "bot" to continue to run. This bot will only be clicking on x,y coordinates within the loaded Applet.
After doing research it seems I would want to fire Mouse events through the AWT event Dispatch onto my JFrame. However this does not seem to work.
I think it is either the case that I am firing events to the wrong component, or am misunderstanding how dispatching mouseEvents actually work.
I am pretty stumped, and am hoping for any suggestions on what to do.
Thanks, -Tony
MouseEvent me = new MouseEvent(getContentPane(), // which
MouseEvent.MOUSE_CLICKED,
System.currentTimeMillis(),
0,
50, 50,
1,
false);
getContentPane().dispatchEvent(me);
UPDATE: My events are in fact getting dispatched, just not onto the applet that is loaded into the JFrame. Why does the Applet not recognize the clicks? perhaps it is clicking behind the applet?
SOLVED: What I needed to do was fire a MOUSE_PRESSED and then MOUSE_RELEASED event. Just firing MOUSE_CLICKED didn't actually do what I wanted. I feel stupid that I spent so much time to figure that out.