Hi,
I’m trying to get the niftyGUI / application interaction working, and have created these files to test it. When I press the created panel, “quitting app” is outputted, but then I get the following exception:
[java]26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker callMethod
WARNING: Exception: java.lang.reflect.InvocationTargetException
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: sun.reflect.NativeMethodAccessorImpl invoke0 (null:-2)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: sun.reflect.NativeMethodAccessorImpl invoke (null:-1)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: sun.reflect.DelegatingMethodAccessorImpl invoke (null:-1)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: java.lang.reflect.Method invoke (null:-1)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.NiftyMethodInvoker callMethod (NiftyMethodInvoker.jav
a:145)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.NiftyMethodInvoker performInvoke (NiftyMethodInvoker.
java:104)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty$DelayedMethodInvoke perform (Nifty.java:1172)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty invokeMethods (Nifty.java:1150)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty handleDynamicElements (Nifty.java:308)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty access$1500 (Nifty.java:73)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl processEvent (Nifty.java
:1367)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl processMouseEvent (Nifty
.java:1325)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.niftygui.InputSystemJme onMouseButtonEventQueued (InputSystemJ
me.java:123)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.niftygui.InputSystemJme forwardEvents (InputSystemJme.java:192
)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty update (Nifty.java:244)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.niftygui.InputSystemJme endInput (InputSystemJme.java:92)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.input.InputManager processQueue (InputManager.java:778)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.input.InputManager update (InputManager.java:842)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.app.Application update (Application.java:596)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.app.SimpleApplication update (SimpleApplication.java:236)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.system.lwjgl.LwjglAbstractDisplay runLoop (LwjglAbstractDispla
y.java:149)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.system.lwjgl.LwjglDisplay runLoop (LwjglDisplay.java:185)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.system.lwjgl.LwjglAbstractDisplay run (LwjglAbstractDisplay.ja
va:223)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: java.lang.Thread run (null:-1)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: Root Cause: java.lang.NullPointerException
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: mygame.StartScreen test (StartScreen.java:48)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: sun.reflect.NativeMethodAccessorImpl invoke0 (null:-2)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: sun.reflect.NativeMethodAccessorImpl invoke (null:-1)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: sun.reflect.DelegatingMethodAccessorImpl invoke (null:-1)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: java.lang.reflect.Method invoke (null:-1)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.NiftyMethodInvoker callMethod (NiftyMethodInvoker.jav
a:145)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.NiftyMethodInvoker performInvoke (NiftyMethodInvoker.
java:104)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty$DelayedMethodInvoke perform (Nifty.java:1172)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty invokeMethods (Nifty.java:1150)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty handleDynamicElements (Nifty.java:308)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty access$1500 (Nifty.java:73)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl processEvent (Nifty.java
:1367)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl processMouseEvent (Nifty
.java:1325)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.niftygui.InputSystemJme onMouseButtonEventQueued (InputSystemJ
me.java:123)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.niftygui.InputSystemJme forwardEvents (InputSystemJme.java:192
)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty update (Nifty.java:244)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.niftygui.InputSystemJme endInput (InputSystemJme.java:92)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.input.InputManager processQueue (InputManager.java:778)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.input.InputManager update (InputManager.java:842)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.app.Application update (Application.java:596)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.app.SimpleApplication update (SimpleApplication.java:236)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.system.lwjgl.LwjglAbstractDisplay runLoop (LwjglAbstractDispla
y.java:149)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.system.lwjgl.LwjglDisplay runLoop (LwjglDisplay.java:185)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.system.lwjgl.LwjglAbstractDisplay run (LwjglAbstractDisplay.ja
va:223)
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: java.lang.Thread run (null:-1)[/java]
This test is based on the tutorial here: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:nifty_gui_java_interaction#java_modifies_nifty_elements_and_events
I read of another user having the same exception but it was due to a problem with the graphics card driver. I’m no expert about this, but 3D graphics display fine in jme3 usually; I’m not sure if this is the problem?
If anybody had any ideas, it would be much appreciated.
Here is the code:
Main.java
[java]package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.renderer.RenderManager;
import de.lessvoid.nifty.Nifty;
public class Main extends SimpleApplication {
protected Nifty nifty;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
nifty = niftyDisplay.getNifty();
nifty.fromXml(“Interface/nifty/niftytest.xml”, “start”);
guiViewPort.addProcessor(niftyDisplay);
flyCam.setEnabled(false);
}
@Override
public void simpleUpdate(float tpf) {
}
@Override
public void simpleRender(RenderManager rm) {
}
}
[/java]
StartScreen.java
[java]
package mygame;
import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
public class StartScreen extends AbstractAppState implements ScreenController {
protected Nifty nifty;
protected Screen screen;
protected SimpleApplication app;
@Override
public void bind(Nifty nifty, Screen screen) {
this.nifty = nifty;
this.screen = screen;
}
@Override
public void onStartScreen() {
}
@Override
public void onEndScreen() {
}
public void quit() {
System.out.println(“quitting app”);
app.stop();
}
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app=(SimpleApplication)app;
}
@Override
public void update(float tpf) {
}
}
[/java]
niftytest.xml
[java]<?xml version=“1.0” encoding=“utf-8”?>
<nifty>
<screen id=“start” controller=“mygame.StartScreen”>
<layer id=“baselayer” backgroundColor="#0000" childLayout=“absolute”>
<panel id=“leftbar” height=“100px” width=“200px” align=“center” valign=“center” backgroundColor="#f60f" childLayout=“center” visibleToMouse=“true” x=“5px” y=“5px”>
<interact onClick=“quit()” />
<text id=“text” font=“aurulent-sans-16.fnt” color="#000f" text=“Hello there” align=“center” valign=“center” />
</panel>
</layer>
</screen>
</nifty>[/java]
Well, one thing that looks a bit strange is that you’re assigning your application instance of this.app in the initialize method of AppState, but I don’t see you attaching your app state to the AppStateManager, so that method would never get called. Also, there’s a System.exit(0) in there which would close down your application anyway.
Anyhow, this.app is null and the quit() method gets called, where you do app.stop(), which should throw a NullPointerException which would then probably throw an InvocationTargetException in Nifty’s reflection code.
However, the stack trace also points to this:
WARNING: Root Cause: java.lang.NullPointerException
26-Feb-2012 00:02:17 de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: mygame.StartScreen test (StartScreen.java:48)
ahh, I see that I need to learn more about appstates, I’ll do that now.
The System.exit(0) I tried to edit out of the post but you managed to see it before I did so! It was to see how initialize was being called, and I wanted the program to quit just to show me that it had. Obviously that never was the case, because of what you have pointed out.
Thanks for your help. I was wondering what you meant by your last statement about the stack trace?
Well, the stack trace seems to indicate a NullPointerException was thrown in a method called test in your StartScreen class, on line 48, but in your code above there is no test-method and no line 48, so it seems the code doesn’t correspond to the error exactly. Perhaps you changed the code a little before posting it, removing the test-method?
Hi, thanks for your reply. The numbers don’t match because I removed some comments that stopped the code from displaying properly in the thread post; was not the wisest thing to do, I apologise.
I’ve used the example files TestAppStates.java and RootNodeState.java to experiment with app states (http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/app/state/). When running the files, the app states work fine. I decided to incorporate my code above, to try and get the implementation of ScreenController to work.
TestAppStates.java
[java]/*
- Copyright © 2009-2010 jMonkeyEngine
- All rights reserved.
*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
*
-
- Redistributions of source code must retain the above copyright
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
*
-
- Redistributions in binary form must reproduce the above copyright
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
*
-
- Neither the name of ‘jMonkeyEngine’ nor the names of its contributors
- Neither the name of ‘jMonkeyEngine’ nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
*
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/
package statetest;
import com.jme3.app.Application;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.scene.Spatial;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext;
public class TestAppStates extends Application {
public static void main(String[] args){
TestAppStates app = new TestAppStates();
app.start();
}
@Override
public void start(JmeContext.Type contextType){
AppSettings settings = new AppSettings(true);
settings.setResolution(1024, 768);
setSettings(settings);
super.start(contextType);
}
@Override
public void initialize(){
super.initialize();
RootNodeState state = new RootNodeState();
viewPort.attachScene(state.getRootNode());
state.initialize(stateManager, this);
stateManager.attach(state);
Spatial model = assetManager.loadModel("Models/Teapot/Teapot.obj");
model.scale(3);
model.setMaterial(assetManager.loadMaterial("Interface/Logo/Logo.j3m"));
state.getRootNode().attachChild(model);
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,
inputManager,
audioRenderer,
guiViewPort);
niftyDisplay.getNifty().fromXml("Interface/nifty/niftytest.xml", "start");
guiViewPort.addProcessor(niftyDisplay);
}
@Override
public void update(){
super.update();
// do some animation
float tpf = timer.getTimePerFrame();
stateManager.update(tpf);
stateManager.render(renderManager);
// render the viewports
renderManager.render(tpf, context.isRenderable());
}
@Override
public void destroy(){
super.destroy();
System.out.println("Destroy");
}
}[/java]
RootNodeState.java
[java]/
- Copyright © 2009-2010 jMonkeyEngine
- All rights reserved.
*
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
*
-
- Redistributions of source code must retain the above copyright
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
*
-
- Redistributions in binary form must reproduce the above copyright
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
*
-
- Neither the name of ‘jMonkeyEngine’ nor the names of its contributors
- Neither the name of ‘jMonkeyEngine’ nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
*
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package statetest;
import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.scene.Node;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
public class RootNodeState extends AbstractAppState implements ScreenController {
protected Application app;
protected Node rootNode = new Node(“Root Node”);
protected Nifty nifty;
protected Screen screen;
protected String stringTest;
public Node getRootNode(){
return rootNode;
}
public void quit() {
app.stop();
}
@Override
public void onEndScreen() {
}
@Override
public void onStartScreen() {
}
@Override
public void bind(Nifty nifty, Screen screen) {
this.nifty = nifty;
this.screen = screen;
}
public String getString() {
return stringTest;
}
@Override
public void update(float tpf) {
super.update(tpf);
rootNode.updateLogicalState(tpf);
rootNode.updateGeometricState();
}
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app=(Application)app;
System.out.println(“initialised: app is “+this.app);
}
}[/java]
niftytest.xml
[java]<?xml version=“1.0” encoding=“utf-8”?>
<nifty>
<screen id=“start” controller=“statetest.RootNodeState”>
<layer id=“baselayer” backgroundColor=”#0000” childLayout=“absolute”>
<panel id=“leftbar” height=“100px” width=“200px” align=“center” valign=“center” backgroundColor="#f60f" childLayout=“center” visibleToMouse=“true” x=“5px” y=“5px”>
<interact onClick=“quit()” />
<effect>
<onStartScreen name=“move” mode=“in” direction=“top” length=“300” startDelay=“0” />
<onEndScreen name=“move” mode=“out” direction=“bottom” length=“300” startDelay=“0” inherit=“true” />
<onHover name=“pulsate” scaleFactor=“0.008” startColor="#f600" endColor="#ffff" post=“true” />
</effect>
<text id=“text” font=“aurulent-sans-16.fnt” color="#000f" text=“Hello there” align=“center” valign=“center” />
</panel>
</layer>
</screen>
</nifty>[/java]
I get the same InvocationTargetException error as before. As you said before, the problem is with “quit()” not having access to the app variable. Why is this the case? Surely the protected “app” variable in the class was assigned the app in initialize?
I’m having an issue understanding the scopes in what is happening, and why a “superclass” needs to be called in every method (isn’t this just the abstract version of the class?), but I don’t expect you to explain to this to me. If you could tell me what I need to do to “fix” the problem, I’d be really grateful
EDIT: Please ignore “stringTest”, I was trying to understand the scopes
I think I see where this went wrong, it’s a common mistake as it’s not obvious how this works in Nifty.
When you specify the RootNodeState as controller for the screen, Nifty creates a new instance of that class, unless you’ve given it an instance (which you don’t do in your code). You also create an instance that you attach to the state manager, but this is then not the same instance as the one Nifty created, so initialize is never called on the Nifty one (btw, initialize is called when you first attach the state to the state manager, you don’t need to call that method yourself).
There are two main ways to solve your problem:
- Pass your RootNodeState (which is also your screen controller) to the fromXml method:
[java]niftyDisplay.getNifty().fromXml("Interface/nifty/niftytest.xml", "start", state);[/java]
Nifty will then use your created instance instead of creating a new one itself.
- Get the RootNodeState (screen controller) from Nifty after the fromXml method and attach it to the state manager first then.
You do this one of the following ways:
a) [java]ScreenController screenController = nifty.getScreen(“start”).getScreenController();[/java]
b) [java]ScreenController screenController = nifty.getCurrentScreen().getScreenController();[/java]
[java]stateManager.attach((AppState)screenController);[/java]
There’s a good reason to call super.initialize for the app state, as that marks the state as initialized. If you don’t call it that variable won’t be set. In the update method, super.update does nothing, currently. Calling super in a method you’ve overriden is often a good idea, but whether it is or not you can decide by checking the code (in Eclipse you can put the text marker on the method and hit F3 and you’ll get to the super method if you have the source code linked, I’m sure it’s similar in Netbeans/jMonkey Platform).
Both of your methods worked a treat!
Thank you very much for your indepth reply!
First of all thank for the Topic. It helped me to solve the same issue.
I had the issue with (Appstate):
[java]
nifty.fromXml("Interface/newbutton.xml", "start");[/java]
I had the same exception.
I solved it like this:
[java]nifty.fromXml("Interface/newbutton.xml", "start", this);[/java]
Thanks again.