Integrating JME into SWT Shell

I’m working on the same Problem. I know that JMonkeyEngine runns the update loop. But the Canvas is not visible. I thought that I have to update the Canvas, but how?

if I use this class I get a get a black Canvas in size of 512x512.

[java]package jme3.swt;

import org.eclipse.swt.SWT;

import org.eclipse.swt.opengl.GLCanvas;

import org.eclipse.swt.opengl.GLData;

import com.ncm.jme.plugin.eclipse.canvas.JmeView;

public class SwtCanvas extends GLCanvas {

private SwtCanvas instance = this;

public SwtCanvas( GLData data) {

super( JmeView.getComposite(), SWT.None, data );

setSize(512, 512);



public int getWidth () {

return getSize().x;


public int getHeight() {

return getSize().y;



I also implementet an updateloop:

[java] new Runnable() {

public void run() {

if (canvas.isDisposed()) return;


System.out.println("Canvas: Width: "+canvas.getWidth()+" Height: "+canvas.getHeight());

System.out.println("Composite: Width: "+canvas.getParent().getSize().x+" Height: "+canvas.getParent().getSize().y);


settings.setResolution(canvas.getParent().getSize().x, canvas.getParent().getSize().y);


canvas.getDisplay().timerExec(50, this);



From this I know that the canvas is changing its Size, but the shown black canvas is still 512x512…

Edit: The Problem is, that the canvas is painted only once. I found it out with this:

[java]addListener (SWT.Paint, new Listener () {

public void handleEvent (Event event) {





Hi! I’m considering to start working on my visualization project again, but I won’t be using any engine other than jme3.

did you manage to fix the repaint issue? If not I’ll try to combine the built-in awt integration with the SWT/AWT bridge and see how it performs.

(sorry if I haven’t contributed to you posts, but at that time I was finishing up my thesis and I stopped checking the forum)

It should be fairly easy to create an SWT compatible canvas. You start with jME3’s “LwjglCanvas” source and just replace all references to AWT/LWJGL to SWT. The critical part is the GLContext.useContext() method which actually allows you to bind LWJGL to an SWT GLCanvas.

I found this snippet of code that shows how to do it:

The parts with the “GL11” calls should be replaced with proper callback to jME3’s SystemListener interface which then goes back to Application.

sorry, but I stoped trying a while ago because I had no success.

If Momoko_Fan 's method works pls let me know