Nullpointerexception at setting the background of an LWJGLCanvas

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


java.lang.NullPointerException
   at com.jme.system.canvas.JMECanvasImplementor.setBackground(JMECanvasImplementor.java:93)
   at com.jmex.awt.lwjgl.LWJGLCanvas.setBackground(LWJGLCanvas.java:170)
   at towerwars.TowerWarsGUI.<init>(TowerWarsGUI.java:91)
   at towerwars.TowerWars$1.run(TowerWars.java:14)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
(etc...)



It happens at this point in my code (in TowerWarsGUI.java):


      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);
      canvas.setUpdateInput(true);
      canvas.setTargetRate(60);
      
      TowerWarsGame twg = new TowerWarsGame(100,100);
      canvas.setImplementor(twg);
      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 jmetest.util.JMESwingTest.java (http://code.google.com/p/jmonkeyengine/source/browse/trunk/src/jmetest/util/JMESwingTest.java 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.

Hi!



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.



regards,

Equilibrium