All I want to do is grab the text value from a Nifty Element
Eclipse is telling me
says TextFieldControl.class is deprecated what should I used instead
<control id=“username_text” name=“textfield” align=“center”
valign=“center” width=“100%” height=“66%”/>
[java]
Element textField = screen.findElementByName(“username_text”);
…
String textValue = textField.getControl(TextFieldControl.class).getText(); //This line says TextFieldControl.class is deprecated
[/java]
Use findNiftyControl and just TextField.class.
What class has the findNiftyControl method I dont see it on Element
Screen.
[java]/**
- A TextFieldControl.
*
-
@author void
-
@deprecated Please use {@link de.lessvoid.nifty.controls.TextField} when accessing NiftyControls.
*/[/java]
Eclipse should display that comment when it encounters an access to the OLD TextFieldControl class. It should tell you: “Please use de.lessvoid.nifty.controls.TextField when accessing NiftyControls.”. This explanation comment was added a couple of weeks back. It could be that it is not yet a part of the Nifty version you use.
[java]public < T extends NiftyControl > T findNiftyControl(final String elementName, final Class < T > requestedControlClass);[/java]
is available on the Screen class as well as on the Element (again it could be that your Nifty is too old since that Element method has just been added a couple of weeks back but it is in the SVN trunk).
Ah I must have me using old code
Im using the nifty-default-controls-1.3-SNAPSHOT.jar from the jme3 nightly build
Are there nightly builds of nifty?
I’m only using JME nightlies and I have Screen.findNiftyControl(). I think it’s just Element.findNiftyControl() that is recent.
But I think that works in your case, doesn’t it?
[java]
TextField textField = screen.findNiftyControl(“username_text”, TextField.class);
String textValue = textField.getText();
[/java]
Nifty nightly builds are available here:
http://nifty-gui.sourceforge.net/nifty-maven-repo/lessvoid/nifty/1.3-SNAPSHOT/
Using Nifty Snapshots with JME requires some skillz and is only recommended for experts tho!
Thanks pspeed and void256. I really appreciate the help.
I downloaded a newer version of the jme3 nightly build and now I see the screen.findNiftyControl().
My next task is to copy the console example.