Hello,
I have an appState which display the menu, but when I disable it I have a NullPointerException :
on my init method I have that :
[java]niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, this.app.getAudioRenderer(), this.app.getGuiViewPort());
/** Create a new NiftyGUI object /
Nifty nifty = niftyDisplay.getNifty();
/* Read your XML and initialize your custom ScreenController */
nifty.fromXml("Interface/MenuGUI.xml", "MainMenu");
// attach the Nifty display to the gui view port as a processor
this.app.getGuiViewPort().addProcessor(niftyDisplay);[/java]
on my enable method (when it called I have a null pointer exception) :
[java]public void setEnabled(boolean enabled)
{
super.setEnabled(enabled);
if(enabled)
{
}
else if(!enabled)
{
this.app.getGuiViewPort().removeProcessor(niftyDisplay);
}
}[/java]
The exception which I have :
[java]java.lang.NullPointerException
at org.LRTeam.Core.MenuState.setEnabled(MenuState.java:100)
at org.LRTeam.Core.Main.switchAppState(Main.java:259)
at org.LRTeam.Core.Main.access$100(Main.java:25)
at org.LRTeam.Core.Main$1.onAnalog(Main.java:200)
at com.jme3.input.InputManager.invokeAnalogs(InputManager.java:244)
at com.jme3.input.InputManager.invokeUpdateActions(InputManager.java:214)
at com.jme3.input.InputManager.update(InputManager.java:852)
at com.jme3.app.Application.update(Application.java:598)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:233)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:182)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)
at java.lang.Thread.run(Thread.java:722)[/java]
tank in avance
where is the NullPointer? in your code or in JME?
Post the stackTrace please
oh yes sorry, I am so stupid ><
I edit my post
stick a breakpoint down on the line it says where the NullPointerException is, im guessing its:
[java]this.app.getGuiViewPort().removeProcessor(niftyDisplay);[/java]
Perhaps setEnabled it called before the top code has executed idk, i cant check this as i’m at work atm.
From the variables window you will be able to see if either:
app is null
niftyDisplay is null
if they both have values then by elimination
getGuiVewPort() returns a null value
Thank you a lot
In fact that niftyDisplay wich is null, but I don’t undestand for what
else, I am stupid this is not the good category, if an moderator can move this topic on GUI troubleshooting I am gratefull to him
sorry but I up this topic, because I have again the bug
I don’t understand for what, when I tryc to debug, I see that is the niftyDisplay which is null, I don’t understand for what
well the idea in debugging is to step through the code, to see where/if niftyDisplay is initialized, or if something is setting it to null
just try this:
[java]
if (niftyDisplay != NULL) {
this.app.getGuiViewPort().removeProcessor(niftyDisplay);
}
[/java]
ok I try that thank ^^
I am sorry I do not know for what but it seem I have not the bug
In fact I know where is the problem,
I used the RC1 release so that is a bug of the RC1 release,
now I have download the stable release and no problem,
I think this is a bug to report
thank a lot to you two