Nullpointerexception at setting the background of an LWJGLCanvas

When I run my program I get the following error ( and are my own files of course):

   at com.jme.system.canvas.JMECanvasImplementor.setBackground(
   at com.jmex.awt.lwjgl.LWJGLCanvas.setBackground(
   at towerwars.TowerWarsGUI.<init>(
   at towerwars.TowerWars$
   at java.awt.event.InvocationEvent.dispatch(
   at java.awt.EventQueue.dispatchEvent(

It happens at this point in my code (in

      DisplaySystem display = DisplaySystem.getDisplaySystem(LWJGLSystemProvider.LWJGL_SYSTEM_IDENTIFIER);
      display.registerCanvasConstructor("AWT", LWJGLAWTCanvasConstructor.class);
      System.out.println(display.getAdapter()); //prints 'null'
      LWJGLCanvas canvas = (LWJGLCanvas)display.createCanvas(100,100);
      TowerWarsGame twg = new TowerWarsGame(100,100);
      System.out.println(display.getRenderer()); //prints 'null'
(line 91)   canvas.setBackground(Color.BLACK);

it seems to happen because the renderer of the displaysystem is null (is that right?), but I don't know why and how to fix that.

My code is based on an example ( from line 172). The example runs on my computer.

I'm running linux (Ubuntu hardy heron), java 1.5.0 and have an NVidia Geforce 6200.


I have got exactly the same problem. As far as I found out, the renderer can only be initialised if you (for example) create a canvas and add it to a componenent. I think the component calls the addNotify method of the canvas and this calls any method which performs the CORRECT init. This also drives me nuts. I can not init a renderer without using the canvas, so the renderer doesn't seem to be independant from the canvas. really strange programming style.

Please answer if you found a good solution.