Embedd JME3 into Swing

Hi there :),

I tried several hours yesterday to integrate a jme3 Canvas into a Swing application and searched some more hours on how to solve the resulting problems. As I did not find any acceptable solution I’m going to ask you.

Embedding the canvas itself works easily just like the tutorial suggests https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:swing_canvas

But as this Canvas is heavyweight and most swing components are lightweight, the canvas hides JMenuBar, JInternalFrame and all other swing elements I want to show “over” the Canvas.

I also tried setting JPopupMenu.setDefaultLightWeightPopupEnabled(false); as suggested on many pages like

Oracle Java Technologies | Oracle

But the menu is still hidden by the canvas.

As of JDK 6 r12 and JDK 7 it should work out of the box according to this site:

Oracle Java Technologies | Oracle

But I’m using JDK 6 r20 and still no success.

One solution would be to use heavyweight awt components but they’re extremely ugly and outdated :wink: I would prefer swing components if anyhow possible.

Any suggestions?

Thanks in Advance,


Look at TestRenderToMemory. Thats what you would have to do to make it work as lightweight swing. You copy the opengl output as an image to the swing canvas.



1 Like

Thanks for your fast reply Normen!

I tried this and it’s working! Unfortunately it’s incredible slow and has a very high cpu load.

Maybe I should drop my idea of using swing in conjunction with jme :/.



Java7 will allow mixing of heavy and lightweight in a more pleasing manner. For now this is the only solution and even if the swing panel is built into the renderer like in jogl its done somehow like this internally.

Well at least hope for java 7 :slight_smile: I really love swing and already did a lot of projects with it.

For now I’ll give swt a chance. Never worked with it yet but maybe this is the right reason to give it a try!

For me in jMP the integration in swing works fine btw. Some small issues, but popups dont get hidden since jdk1.6_20 anymore, SWT had lots of problems on osx in jme2…

Oh ok that’s interesting. Maybe I should try on a 32bit or a windows jvm. Small issues would be ok as I’m sure java7 will come out before I release my project ;).