NullPointerException when calling DisplaySystem.createWindow()

Hi All,

I'm working from the tutorial with FengGUI (The FengJME one, here:

After sorting out the libraries, updating some things, and making it speak jME 2.0, I'm getting a NullPointerException when I create the display (which in turn gives a mouse error since there is no display)

FYI, I'm having this problem on both a Macbook Pro and a pretty hefty Vista 64 machine

For ease of reading, this is Line 173, where the exception originates:

display.createWindow(1024, 768, 24, properties.getFrequency(), false);

And here's the entire file:

package edu.poly.bxmc.betaville.jme.fenggui;

import org.fenggui.ComboBox;
import org.fenggui.TextEditor;
import org.fenggui.composite.Window;
import org.fenggui.event.ISelectionChangedListener;
import org.fenggui.event.SelectionChangedEvent;
import org.fenggui.layout.StaticLayout;
import org.fenggui.binding.render.lwjgl.LWJGLBinding;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.MouseInput;
import com.jme.light.PointLight;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.shape.Box;
import com.jme.scene.state.LightState;
import com.jme.scene.state.ZBufferState;
import com.jme.system.DisplaySystem;
import com.jme.system.JmeException;
import com.jme.util.Timer;
import com.jme.util.lwjgl.LWJGLTimer;
 * FengJME - A test class for integrating FengGUI and jME. (From JMonkey Wiki)
 * @author Josh (updated by neebie)
public class FengJME extends BaseGame
   Camera cam; // Camera for jME
   Node rootNode; // The root node for the jME scene
   PointLight light; // Changeable light
   FengJMEInputHandler input;
   Timer timer;
   DisplaySystem display;
   DisplaySystem properties;
   Box box; // A box
   org.fenggui.Display disp; // FengGUI's display
   /* (non-Javadoc)
    * @see
   protected void cleanup()
      // Clean up the mouse
      // Clean up the keyboard
   /* (non-Javadoc)
    * @see
   protected void initGame()
      // Create our root node
      rootNode = new Node("rootNode");
      // Going to enable z-buffering
      ZBufferState buf = display.getRenderer().createZBufferState();
      // ... and set the z-buffer on our root node
      // Create a white light and enable it
      light = new PointLight();
      light.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
      light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
      light.setLocation(new Vector3f(100, 100, 100));
      /** Attach the light to a lightState and the lightState to rootNode. */
      LightState lightState = display.getRenderer().createLightState();
      // Create our box
      box = new Box("The Box", new Vector3f(-1, -1, -1), new Vector3f(1, 1, 1));
      // Rotate the box 25 degrees along the x and y axes.
      Quaternion rot = new Quaternion();
      rot.fromAngles(FastMath.DEG_TO_RAD * 25, FastMath.DEG_TO_RAD * 25, 0.0f);
      // Attach the box to the root node
      // Update our root node
      rootNode.updateGeometricState(0.0f, true);
      // Create the GUI
    * Create our GUI.  FengGUI init code goes in here
   protected void initGUI()
      // Grab a display using an LWJGL binding
      //      (obviously, since jME uses LWJGL)
      disp = new org.fenggui.Display(new LWJGLBinding());
      input = new FengJMEInputHandler(disp);
      //    Create a dialog and set it to some location on the screen
      org.fenggui.composite.Window frame = new org.fenggui.composite.Window();
      frame.setSize(200, 100);
      frame.setTitle("Pick a color");
      frame.getContentContainer().setLayoutManager(new StaticLayout());
      // Create a combobox with some random values in it
      //   we'll change these values to something more useful later on.
      ComboBox list = new ComboBox();
      list.setSize(150, list.getMinHeight());
      list.addSelectionChangedListener(new CBListener());
      //try to add TextArea here but get OpenGLException
      TextEditor ta = new TextEditor();
      ta.setText("Hallo Text");
      //ta.setSize(100, ta.getAppearance().getFont().get)
      // Update the display with the newly added components
   /* (non-Javadoc)
    * @see
   protected void initSystem()
         // Initialize our jME display system
         display = DisplaySystem.getDisplaySystem();
         display.createWindow(1024, 768, 24, properties.getFrequency(), false);
         //display.createWindow(properties.getWidth(), properties.getHeight(), properties.getBitDepth(),
         //      properties.getFrequency(), properties.isFullScreen());
         // Get a camera based on the window settings
         cam = display.getRenderer().createCamera(display.getWidth(), display.getHeight());
      catch (JmeException ex)
      /** Set a black background.*/
      /** Set up how our camera sees. */
      cam.setFrustumPerspective(45.0f, (float) display.getWidth() / (float) display.getHeight(), 1, 1000);
      Vector3f loc = new Vector3f(0.0f, 0.0f, 15.0f);
      Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
      Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
      Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
      /** Move our camera to a correct place and orientation. */
      cam.setFrame(loc, left, up, dir);
      /** Signal that we've changed our camera's location/frustum. */
      /** Assign the camera to this renderer.*/
      // We want a cursor to interact with FengGUI
      // Bind the Escape key to kill our test app
      KeyBindingManager.getKeyBindingManager().set("quit", KeyInput.KEY_ESCAPE);
      // Create our timer
      timer = new LWJGLTimer();
   /* (non-Javadoc)
    * @see
   protected void reinit()
      // TODO Auto-generated method stub
   /* (non-Javadoc)
    * @see
   protected void render(float interpolation)
      // First we draw our jME scene.  This must be called before
      //   anything will even show up.
      //   FIXME: This throws a NullPointerException when the app exits.
      //          Must investigate why.
      // We could draw the GUI here, but I find it cleaner to just do
      //    all the jME engine calls together.
      // Then we display the GUI
   /* (non-Javadoc)
    * @see
   protected void update(float interpolation)
      float tpf = timer.getTimePerFrame();
      if (!input.wasKeyHandled())
         // Check to see if Escape was pressed
         if (KeyBindingManager.getKeyBindingManager().isValidCommand("quit")) finish();
    * @param args
   public static void main(String[] args)
      FengJME app = new FengJME();
   private class CBListener implements ISelectionChangedListener
      public void selectionChanged(SelectionChangedEvent selectionChangedEvent)
         if (!selectionChangedEvent.isSelected()) return;
         String value = ((TextEditor) selectionChangedEvent.getToggableWidget()).getText();
         if ("White".equals(value)) light.setDiffuse(ColorRGBA.white);
         if ("Red".equals(value)) light.setDiffuse(;
         if ("Blue".equals(value)) light.setDiffuse(;
         if ("Green".equals(value)) light.setDiffuse(;

Console Output:

Jun 10, 2009 7:16:20 PM start
INFO: Application started.
Jun 10, 2009 7:16:20 PM com.jme.system.PropertiesGameSettings <init>
INFO: PropertiesGameSettings created
Jun 10, 2009 7:16:20 PM com.jme.system.PropertiesGameSettings load
INFO: Read properties
Jun 10, 2009 7:16:23 PM com.jme.system.PropertiesGameSettings save
INFO: Saved properties
Jun 10, 2009 7:16:23 PM com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
Jun 10, 2009 7:16:23 PM class edu.poly.bxmc.betaville.jme.fenggui.FengJME start()
SEVERE: Exception in game loop
at edu.poly.bxmc.betaville.jme.fenggui.FengJME.initSystem(
at edu.poly.bxmc.betaville.jme.fenggui.FengJME.main(
Jun 10, 2009 7:16:23 PM com.jme.input.lwjgl.LWJGLMouseInput <init>
WARNING: Problem during creation of Mouse.
java.lang.IllegalStateException: Display must be created.
at org.lwjgl.input.Mouse.create(
at com.jme.input.lwjgl.LWJGLMouseInput.<init>(
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.jme.input.MouseInput.get(
at edu.poly.bxmc.betaville.jme.fenggui.FengJME.cleanup(
at edu.poly.bxmc.betaville.jme.fenggui.FengJME.main(
Jun 10, 2009 7:16:23 PM start
INFO: Application ending.

Thanks for any help.. I'm so close I can taste it