Nifty NPE at de.lessvoid.nifty.screen.Screen.forwardMouseEventToLayers

Hi there,

we changed to the new JME 3 SDK with all its libraries. For that i have to change NiftyTab to Tab and Tabs to TabGroup. This worked out fine.

But if i move the mouse while the Screen is loading, the correct Screen is showing but just for about 0,2 Sec. After that everything crashs with a NPE:

java.lang.NullPointerException: null
at de.lessvoid.nifty.screen.Screen.forwardMouseEventToLayers(Screen.java:352) ~[nifty.jar:na]
at de.lessvoid.nifty.screen.Screen.mouseEvent(Screen.java:339) ~[nifty.jar:na]
at de.lessvoid.nifty.Nifty.forwardMouseEventToScreen(Nifty.java:308) ~[nifty.jar:na]
at de.lessvoid.nifty.Nifty.access$1600(Nifty.java:77) ~[nifty.jar:na]
at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processEvent(Nifty.java:1373) ~[nifty.jar:na]
at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processMouseEvent(Nifty.java:1329)
~[nifty.jar:na]
at com.jme3.niftygui.InputSystemJme.handleMouseEvent(InputSystemJme.java:134)
~[jME3-niftygui.jar:na]
at com.jme3.niftygui.InputSystemJme.onMouseButtonEventQueued(InputSystemJme.java:197)
~[jME3-niftygui.jar:na]
at com.jme3.niftygui.InputSystemJme.forwardEvents(InputSystemJme.java:261) ~[jME3-niftygui.jar:na]
at de.lessvoid.nifty.Nifty.update(Nifty.java:288) ~[nifty.jar:na]
at com.jme3.niftygui.InputSystemJme.endInput(InputSystemJme.java:113) ~[jME3-niftygui.jar:na]
at com.jme3.input.InputManager.processQueue(InputManager.java:819) ~[jME3-core.jar:na]
at com.jme3.input.InputManager.update(InputManager.java:883) ~[jME3-core.jar:na]
at com.jme3.app.Application.update(Application.java:604) ~[jME3-core.jar:na]
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:231) ~[jME3-core.jar:na]
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
~[jME3-lwjgl.jar:na]
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185) ~[jME3-lwjgl.jar:na]
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
~[jME3-lwjgl.jar:na]
at java.lang.Thread.run(Thread.java:722) ~[na:1.7.0_11]

I red that this Exception was thrown in older Nifty Versions. But i use the new Version of JME3. Does anyone have any clues how to fix this problem.

If i don’t move the Mouse while the Screen is loading it works out find.

Thx for your efforts
Stefan

Problem solved!

I think new NiftyJmeDisplay() was the Problem because it was the second initialisation of NiftyDisply.

To find the Controlls and Elements after addingXML and registering ScreenControlle I had to call
nifty.executeEndOfFrameElementAction (what ever this does :slight_smile: ).

Im having this same issue. When I move my mouse as I am switching between gui’s, the program crashes with a NPE. Where did you add nifty.executeEndOfFrameElementActions()? I tried adding that but it didnt seem to help. Can anyone help me out?