What to use instead of this Nifty is telling me its deprecated but its from their example

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%”/>


Element textField = screen.findElementByName(“username_text”);

String textValue = textField.getControl(TextFieldControl.class).getText(); //This line says TextFieldControl.class is deprecated


Use findNiftyControl and just TextField.class.

What class has the findNiftyControl method I dont see it on Element



  • A TextFieldControl.

  • @author void
  • @deprecated Please use {@link de.lessvoid.nifty.controls.TextField} when accessing NiftyControls.


    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?


TextField textField = screen.findNiftyControl(“username_text”, TextField.class);

String textValue = textField.getText();


Nifty nightly builds are available here:


Using Nifty Snapshots with JME requires some skillz and is only recommended for experts tho! :smiley:

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.