Jmecanvas usage with swing

Hi everybody, I have a question about the way to use the jmecanvas.

I have a swing application and i am already using jmecanvas and I extended Simplecanvasimpl for my use…

I have four canvas that display four different scenes in my app and I would like to know a way of extending canvas with keeping the JMEcanvas fonctions. 

I want to do this because I took the JMESwingtest class to start and I've just added the repaints of the four canvas into the thread that was already there… 

The problem is that the yield function of the thread doesn't seem to work well with my application : it is a multi-internal frame app. And I needed to put a sleep instead of a yield to make it work better.

But it still makes the app crash from time to time with this dump:


An unexpected error has been detected by HotSpot Virtual Machine:


#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00add6df, pid=11864, tid=15616


Java VM: Java HotSpot™ Client VM (1.5.0_06-b05 mixed mode, sharing)

Problematic frame:

j  org.lwjgl.opengl.GL11.glViewport(IIII)V+0


An error report file with more information is saved as hs_err_pid11864.log


If you would like to submit a bug report, please visit:


that's why i wanted to extend Canvas and have the thread in the my canvas class to see if the problem would be fixed but I don't understand how to extend canvas and still have the jmecanvas fonctionnalities… 

Hope i'm clear …

Someone as an idea?


You must call jME changes within the graphical thread and you must call Swing/AWT changes within the AWT thread.  When you don't obey that rule is when the VM crashes come down on you hard. :-p


Thanks for the reply.

I understand the problem with updating graphical changes with the awt thread  but I dont really understand how to manage the updating of the jme changes within a different thread…  I' m using the JMESwingtest…  Does someone know how i could implement this functionnality? 

thanks in advance for the help…

I recall Irrisor talking about a JMEAction or something that would be invoked within the jME graphical thread…



The basic way to get around the problem is create a stack that has a list off all the comands you want to execute. You then add the action to the stack from the swing frames and call the action in the jme form.

Darkfrog stated

darkfrog said:

You must call jME changes within the graphical thread and you must call Swing/AWT changes within the AWT thread.

That's partially correct. Though in JMESwingTest the graphical thread is the Swing/AWT thread. So any gl related calls must happen in the Swing thread.
Thus you can use SwingUtils.invokeLater or invokeAndWait to decouple the calls from a probably different thread.

In any jME application that updates an InputHandler in the graphical thread you can use JMEAction. See HelloJMEDesktop for a usage example - it's really simple. You can use it a JMESwingTest-like application, too.

Thanks everyone for the quick help.

My problem seems to come when the state of the internal frame that displays my 4 3d scenes changes state.  It all goes well and smooth when i maximize or restore the frame but when I hide the "outlook style" left toolbar of my desktoppane and the internalframe normally would use all of the desktop pane, often, the vm crashes or I get a exception saying that lwjgl cannot find the pixel format : -23494584  or something like that…  I would like to know if it's possible for me to know by event if my internalframe is being maximized in the desktop pane because I could then stop refreshing of the jme scenes. 

thanks for replys…