Attaching a JME3 to a JFrame

Hey Guys, I am currently doing a project that requires both Swing JFrame/JPanel and the JME3 3d stuff… The problem I am facing is the integration part. Is it possible to attach the JME3 .java to the JFrame?

Welcome to the forum :slight_smile:



Yes, its possible. The following code sample might be what you are looking for,



http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/awt/TestCanvas.java



http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/awt/TestSafeCanvas.java

1 Like

Thanks for the quick reply :slight_smile: It works briliantly. thanks!

Beware if you put it together Swing mouse events are not capture by JME.

Yep, always use app.enqueue(callable) to modify the scene, all your button presses etc. are on the AWT Event Dispatch Thread.

If you use AWT panels you can get AWT events but its more CPU intensive:



http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/awt/TestAwtPanels.java

Wow, thanks so much for the warnings. I nearly made that mistake of putting in Swing events. Thanks so much