Hi! I’m new to NiftyGUI… I’ve been reading some things here at jmonkey forum as well as the Nifty Tutorials. I’ve been trying the demo as well… But I can’t seem to understand why it keeps giving me a NullPointer Exception… Here’s a very very very simple code that I’m doing…
[java]TextField textfield = nifty.getScreen(“hud”).findNiftyControl(“countryText”, TextField.class);
System.out.println(textfield.getText());[/java]
and I keep getting this error everytime I try to get something from the textfield
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] java.lang.NullPointerException at de.lessvoid.nifty.controls.label.LabelControl.getTextRenderer(LabelControl.java:61) at de.lessvoid.nifty.controls.label.LabelControl.getText(LabelControl.java:47) at app.main.Main.simpleInitApp(Main.java:88) at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225) at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207) at java.lang.Thread.run(Thread.java:662)
Here’s my XML
[java]control height=“26px” id=“countryText” name=“textfield” width=“212px” x=“60” y=“0” maxLength=“20” text=“Some Text”[/java]
I’m also trying to do a setText(“Some Text”) and for some reason it keeps giving me NullPointerException… I’m getting really frustrated and I badly need help… :’(