Multiple Application instances in Swing


Once I asked the question if it is possible to use multiple application instances within swing. The answer was that this will not work the way I suppose it to work? What exactly is the reason?

If it would work (another way) could Materials, Textures etc created by one AssetManager be shared within the two different applications?

If such a support is not included will there be one in future and if not, why? Is there a restriction from within opengl for that or is Java the problem?

Thanks a lot.



Its a restriction of lwjgl.

Damn. I hate lwjgl for this…:slight_smile:

Do it like I do in JMP when you actually want to share the assets and make a lightweight Swing panel from jME previews.


thanks but I need mor than only previews. Nevertheless I’ll look at your code.



… “preview” is just another name for those views in the renderer that are rendered before the main view, theres no restrictions to them per se, only that they dont render to screen directly.


but they are lightweight components?

No, its a function of the jME renderer, it has nothing to do with swing, it just creates the image data, look at for an example.

LWJGL actually supports multiple canvases through its AWTGLCanvas class, however it is slower than using the Display.setParent() method.

Hello Momoko,

this is really good news. What I would now be interessted in is following.

The fact that lwjgl supports multiple AWTGLCanvas canvases means that the result is rendered to swing (or AWT in that case) panels, right? How can I perform this in my code and the most important question, can I use two Application instances for that? I need multiple separate application instances. The last question would be if the materials, textures etc. which are created from one AssetManager of one application could be used by the other application.

Thanks a lot,



An AWTGLCanvas is not a panel, it works the same way as the current way canvases work in jME3, except you can have more than one. It is possible to render to a panel, for that you have TestRenderToMemory.

Sharing the GL objects from one instance to another is possible, if you use context sharing, its fairly simple to enable it in LWJGL