Im new to nifty and Im trying to change text control using nifty in JME application following this tutorial.
Below is my TextRenderer code:
Element element = nifty.getScreen("loadlevel").findElementByName("loadingtext");
TextRenderer textRenderer = element.getRenderer(TextRenderer.class);
textRenderer.setText("loadingText");
Below is my nifty GUI code code for loadLevel scene:
<screen id="loadlevel" controller = "jmebase.TestLoadingScreen">
<layer id="loadinglayer" childLayout="center" backgroundColor="#000000">
<panel id = "loadingpanel" childLayout="vertical" align="center" valign="center" height="32px" width="70%">
<control name="loadingbar" align="center" valign="center" width="100%" height="100%" />
<control id="loadingtext" name="label" align="center"
text=" "/>
</panel>
</layer>
</screen>
I printed value of for both element and textRenderer. element is initialised properly but textRenderer object is null. I googled lot and lots of people got this issue but none provided appropriate solution. Anyone know how to fix it. Im really stuck need help.
Controlis a composition, consisting of multiple basic elements. The loadingtext element is actually not a text element but it has a nested text inside. You should get the Label Control from loadingtext. It has a setText method. Sorry, i'm on my phone. I can elaborate later. \$\endgroup\$Labelmy comment was wrong. Because aLabelonly consists of a single text element, the control tag effectively gets replaced by this text element. \$\endgroup\$