Dispatch simulated events
I'm trying to build an helper tool in Java for an online game. It must display some popup menus (and little else) when I press some keys while playing. A native method (which I wrote myself) correctly returns to me data about the in-game pressed keys, as an array of KeyEvents.
Now, I need to dispatch them to my application, in a clean and safe way.
1 - What should I set as the source of the KeyEvent? (for KeyEvent.getSource())
2 - To what method should I pass the event? Is there a "global" method, or should I proceed component by component?
3 - My application is always in foreground (the user is supposed to be playing the game!). Does this bring up problems?
I tried to figure out it myself, but I'm confused by dozens of "postAwtEvent", "processAwtEvent", "dispatchAwtEvent" methods in dozens of Component classes and utility classes. And I'm concerned about the background/foregound problem as well.
Thanks in advance!
PS: Please, no java.awt.Robot tricks. They're not what I mean for "a clean and safe way".