Nifty TextField getText() and DropDown question

Hello,



I really dont understand how you can read out Textfields as a String. There is a getText() method but i do not understand how to use it.



Second Thing In the DropDown i cannot use the addItem allthough it is stated in the nifty-wiki.



Here is some code.



[java]

// The ScreenController



public class SGScreenController implements ScreenController {



@Override

public void bind(Nifty nifty,

Screen screen){

}

@Override

public void onStartScreen() {

}

@Override

public void onEndScreen() { }

public void switchtoMainMenu(){

nifty.gotoScreen("MainMenu");

}

public void switchtoGame(){

//nifty.getScreen("SGScreen").findElementByName("h1nameselect").getText(); <-- This does not work…but why?

loadMap();

}

}

[/java]



[java]



// The Screen Layout



Screen SGscreen = new ScreenBuilder("SGScreen"){{

controller(new SGScreenController());

layer(new LayerBuilder("dialogLayer") {{

childLayoutCenter();

panel(new PanelBuilder("dialog-parent"){{

height("400px");

width("600px");

style("nifty-panel");

align(Align.Center);

valign(VAlign.Center);

childLayoutVertical();

panel(new PanelBuilder("h1selectpanel"){{

height("60px");

width("400px");

style("nifty-panel-no-shadow");

align(Align.Left);

valign(VAlign.Top);

childLayoutHorizontal();

control (new DropDownBuilder("h1classselect"){{

width("200px");

height("100px");

align(Align.Left);

valign(VAlign.Top);

//addItem("Paladin"); <-- This also does not work.

}});

control (new TextFieldBuilder("h1nameselect"){{

width("120px");

height("23px");

align(Align.Left);

valign(VAlign.Top);

}});

}});





control(new ButtonBuilder("SGBackButton"){{

label("Back");

width("80px");

height("40px");

align(Align.Right);

valign(VAlign.Bottom);

interactOnClick("switchtoMainMenu()");

}});

control(new ButtonBuilder("SGOkButton"){{

label("OK");

width("80px");

height("40px");

align(Align.Right);

valign(VAlign.Bottom);

interactOnClick("switchtoGame()");

}});

}});

}});

}}.build(nifty);

[/java]



So i need some help here.



Thanks in advance

Thorsten

OK, solved it myself. Of course i had to state the class of the element i have tu “speak” to.



So i put this line in:



[java]

String ta = nifty.getScreen(“SGScreen”).findNiftyControl(“h1nameselect”, TextField.class).getText();

[/java]

for the TextField and



[java]

nifty.getCurrentScreen().findNiftyControl(“h1classselect”, DropDown.class).addItem(“Paladin”);

[/java]

for the DropDown.



Anyway thanks