The problem: For various reasons, some people had been wanting to use JMEDesktop in a JME Swing application (like RenParticle Editor), however, they were having difficulties with components on the JMEdesktop responding to input.
The nature of this bug is the code in JMEDesktop which causes this error on a Swing app
Exception in thread "AWT-EventQueue-1" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
at java.awt.EventQueue.invokeAndWait(Unknown Source)
at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
Basically, the invokeAndWait() method call is trying to dispatch the runnable to the event dispatching thread and then wait for it to finish.
However, obviously, it is not possible to do this from the event dispatching thread. You can't dispatch to your own thread and then wait for yourself. You will be deadlocked waiting for yourself to run the runnable, because you are busy waiting for yourself.
Sooo, To fix this I modified JMEDesktop and renamed it to UnsafeDesktop
And here is a Test case displaying it 'working' (see below)
Gotchas: So although I have made a proof-of-concept that ti could work I found the following hiccups:
1.) The performance of JMEDesktop sucks!
I had determined that JMEDesktop was just way too slow and too unreliable to meet my requirements, so this is only a partial solution to the whole problem. Maybe if the missing events were solved I'd use it, seems that half of the events are not registered
(see http://www.jmonkeyengine.com/jmeforum/index.php?topic=10546.0 )
2.) The Y axis of component mouse picking needs to be modified
JMEDesktop assumes its working in a non-canvas, but implimenting the canvas inverts the mouse position for whatever reason. Since the performance wasn't up to par, I didn't bother to fix the Y axis registration, I'll leave that up to you, (hint: you'll want to pass the height of the canvas and subtract it from the mouse for the proper mouse). So you'll see in my test application the button is in the center verticly
(ps, You need to be logged in to see/download the attachments, )