Swing Listeners work in Linux, but not in Windows?

Hello everyone!

i’ve made jme in a swing canvas, following the tutorial. My project consists of two classes, one for the GUI, one for the Listeners. I’m the using the Swing/AWT MouseListener and modify the spatials by a Callable. My aim is to get red sphere to the Mouse/Object Collision point. It’s working in Linux, but not in Windows, tested with the same jar.

In the GUI Class, i add the listener, more precisely gc class, to the canvas:


In the Listener Class, following the picking tutorial:

public void mouseReleased(MouseEvent e) {

shot(e.getPoint().x, e.getPoint().y);


public void shot(int x, int y) {

Vector2f click2d = guiClass.getInputManager().getCursorPosition();

Vector3f click3d = guiClass.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f).clone();

Vector3f dir = guiClass.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d);

Ray ray=new Ray(click3d, dir);

final CollisionResult closest = results.getClosestCollision();

System.out.println("Shot at " + closest.getGeometry().getName() + " bei " +closest.getContactPoint() + “, " + closest.getDistance() + " wu away.”);

Future fut = guiClass.enqueue(new Callable() {

public Object call() throws Exception {

//mark =red sphere


return guiClass.mark;



try {


}catch …

Why doesn’t the Picking work with Windows? Everything else does, and even the camera drag-funktion works.


You are directly calling from the AWT Event Dispatch thread to the OpenGL runloop which can basically result in anything. You have to use callables to enqueue the calls to the right thread. Read up on “Swing threading” (cause you probably did a lot of threading stuff with swing wrong until now if you’re not aware of this) and our tutorials on the update loop etc. Then always use Callables when reading or modifying stuff in the scene:

[snippet id=“10”]

To go back to swing and change stuff there, use the awt EventQueue.

Can you tell me, what I did wrong? I’ve read your tutorials again and from the start on I did follow your suggestion to use Futures to enqueue - guiClass.enqueue(new Callable() - the Code to the OpenGL-Thread in order not to call the geomentry transformations directly from the AWT thread.