Popup dialog on mousepick?

Hi,

I want to get a (swing) dialog on mousepick of objects in my worlds, but I cant find any tutorial about such.

By playing around with HelloJMEDesktop-code, Im able to popup a dialog-box when I click on a button on the desktop, but if I try to move ’ showDialog(); ’ into my mousepick-function, I get a



Exception in game loop

java.lang.IllegalStateException: not in swing thread!

at com.jmex.awt.swingui.JMEDesktop.dispatchEvent(JMEDesktop.java:669)

at com.jmex.awt.swingui.JMEDesktop.setFocusOwner(JMEDesktop.java:891)

at com.cyworx.game.app.MapDrag.showDialog(MapDrag.java:485)

at com.cyworx.game.app.MapDrag.simpleUpdate(MapDrag.java:328)

at com.jme.app.SimpleGame.update(SimpleGame.java:60)

at com.jme.app.BaseGame.start(BaseGame.java:84)

at com.cyworx.game.app.MapDrag.main(MapDrag.java:101)





So how can I make it, to open a dialog by clicking a 3D object im my world?

Can someone point me in the right direction, or have an example for me to do such?



Thanx in advance.

If its complaining its not in the swing thread, then do it via the swing thread:

java.awt.EventQueue.invokeLater(myExecutingCallable);

1 Like

Great! Thank you very much!



It works, I added in simpleUpdate() where my mousepick is now:



EventQueue.invokeLater(new Runnable() { public void run() {

showDialog();

}

});



Thank you for your help! :smiley: