I finally got NiftyGUI to work. It will display controls on its own screen from my xml file. I reread the tutorial at http://nifty-gui.lessvoid.com/ many times. The code at http://sourceforge.net/apps/mediawiki/nifty-gui/index.php?title=Layout_Introduction was very helpful.
However, I have not been able to figure out how to read the text typed into a textfield called ‘name’ when I onClick a ‘connect’ button. I have looked through the javadocs and all that I could find was getOriginalText; which is close, but not what I wanted. The following println does work when I click the button.
Here is my code:
package com.gaeliclegendsgame.client;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.elements.render.TextRenderer;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
/**
*
* @author Chapman
*/
public class StartScreen implements ScreenController {
public void onStartScreen() {
}
public void onEndScreen() {
}
public void bind(Nifty fifty, Screen screen) {
}
// The callback routine for the Connect button.
public void connect() {
// getElement("password").getRenderer(TextRenderer.class).setText("");
System.out.println("connect() called.");
}
private Element getElement(final String id) {
return nifty.getCurrentScreen().findElementByName(id);
}
Nifty nifty = mygame.Main.getNifty();
}
Any help will be appreciated. :D