Hello. I’ll get straight to the point - I can’t populate the ListBox nifty gui panel with any data. I tried several other solutions presented in this forum but I still can’t seem to get it to work. The class that implements this GUI is an extension of abstractAppState class. Can anyone see anything wrong with this code?
[xml]
<?xml version=“1.0” encoding=“UTF-8”?>
<nifty>
<useControls filename=“nifty-default-controls.xml” />
<useStyles filename=“nifty-default-styles.xml” />
<screen id=“start”>
<layer id=“background” childLayout=“center”>
<image filename=“Interface/underground-background.jpg”></image>
</layer>
<layer id=“layerWithButtons” childLayout=“center” height=“75%”>
<panel id=“panelTop” height=“75%” width=“500px” align=“center” valign=“center” childLayout=“center” visibleToMouse=“true”>
<control id=“myListBox” name=“listBox” horizontal=“false” width=“75%” height=“100%” childLayout=“vertical” visibleToMouse=“true”>
<panel id=“myListBoxData” width=“100%” hwight=“100%” childLayout=“vertical” visibleToMouse=“true”>
<label text=“Static Item I” style=“my-listbox-item-style” />
<label text=“Fo Shizzle” style=“my-listbox-item-style” />
<label text=“Static Item III” style=“my-listbox-item-style” />
<label text=“Static Items ftw” style=“my-listbox-item-style” />
</panel>
</control>
</panel>
</layer>
</screen>
<screen id=“end”>
</screen>
</nifty>
[/xml]
and my Java looks like this:
[java]
package views;
import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.asset.AssetManager;
import com.jme3.audio.AudioRenderer;
import com.jme3.bullet.BulletAppState;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.input.FlyByCamera;
import com.jme3.input.InputManager;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;
import com.jme3.system.AppSettings;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.controls.ListBox;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
/**
*
-
@author pawelgasiorowski
/
public class StartScreen extends AbstractAppState implements ScreenController {
private SimpleApplication app;
private Node rootNode;
private AssetManager assetManager;
private AppStateManager stateManager;
private InputManager inputManager;
private ViewPort viewPort;
private BulletAppState bullet;
private Node guiNode;
private AppSettings appSettings;
private AudioRenderer audioRenderer;
private BitmapFont guiFont;
private BitmapText hudText;
private FlyByCamera flyByCamera;
private int number = 0;
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
this.app = (SimpleApplication) app;
this.rootNode = this.app.getRootNode();
this.assetManager = this.app.getAssetManager();
this.stateManager = this.app.getStateManager();
this.inputManager = this.app.getInputManager();
this.viewPort = this.app.getViewPort();
this.guiNode = this.app.getGuiNode();
this.audioRenderer = this.app.getAudioRenderer();
this.flyByCamera = this.app.getFlyByCamera();
// nifty experiment
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(
assetManager, inputManager, this.audioRenderer, this.viewPort);
/* Create a new NiftyGUI object /
Nifty nifty = niftyDisplay.getNifty();
/* Read your XML and initialize your custom ScreenController */
nifty.fromXml("Interface/screen.xml", "start");
//nifty.setDebugOptionPanelColors(true);
// nifty.fromXml("Interface/helloworld.xml", "start", new MySettingsScreen(data));
// attach the Nifty display to the gui view port as a processor
this.viewPort.addProcessor(niftyDisplay);
// disable the fly cam
this.flyByCamera.setDragToRotate(true);
this.flyByCamera.setEnabled(false);
}
// SimpleUpdate
@Override
public void update(float tpf)
{
}
public void bind(Nifty nifty, Screen screen) {
ListBox listbox = nifty.getCurrentScreen().findNiftyControl("myListBox", ListBox.class);
listbox.addItem("afasd");
listbox.addItem("bafsd");
listbox.addItem("fasdc");
}
public void onStartScreen() {
}
public void onEndScreen() {
}
}
[/java]
Any help most appreciate it!