NIfty ListBox's index's string value retrieval

I’m having difficulties grabbing what has been entered into the listbox. By using the SelectionListener I get the index the user clicked on, but I can’t seem to retrieve the values that have been put there.

Do I have to store what is in there in a separate ArrayList or whatever? Sounds counter-productive to me.

The info is properly stored, properly displayed I should say.

The listener being added.


lbc.addSelectionListener(new ListBoxControl.SelectionListener() {


public void onSelectionChanged(ListBoxControl listboxControl, int indexSelection) {

fillInfo(listboxControl.getElement(), indexSelection);





// fill info into top right area of info panel about selection

private void fillInfo(Element el, int index) {

Element eInData = el.findElementByName(“stellarBodiesBoxData”);

for (Element elementData : eInData.getElements()) {

if (elementData.getId().equals(String.valueOf(index))) {

// sifting through the data, I can’t FIND the value of the entered data. Into what is it stored!?

// How can it be retrieved? Or maybe we’ll have to wait for 1.3 to have that feature enabled?





Also. There seem to be a weird behavior when I reset the Data.

As an example: Every time the user hit I, a “popup” (it’s actually a simple panel that is toggled visible or not) appears and is filled with the necessary information. Now, the first time this happens, the indices are correct. Meaning the first item = 0, the second = 1, etc. But, on successive opens, the index gets augmented by the previous number of items.

Let’s say the first time the listbox had 10 items. (indices from 0 - 9). The second time we have 6 items. The indices will be from 10 - 15, not 0 to 5.

I guess it’s probably the way I “remove” those previously in the listbox. Here’s the way I do it:


private void clearListBox() {

Element e = nifty.getCurrentScreen().findElementByName(“stellarBodiesBoxData”);

for (final Element ele : e.getElements()) {





That’s the only way I could do it.


So huh, nothing? :frowning:

Void? Please? :’( :cry:

I think void is changing this in nifty 1.3. All the controls will have these useful methods that you would normally expect them (for example, list box will have methods for adding, changing, removing items as well as getting currently selected items and changing selection mode).

Or at least, that is what I get from reading his blog… :slight_smile:

Yeah, I’m already using the latest nifty 1.3 codebase and it all works like a treat. I’ll see if I can get you an example on how your problem would be dealt with in 1.3 later tonight when I’m home from work.

ractoc said:
Yeah, I'm already using the latest nifty 1.3 codebase and it all works like a treat. I'll see if I can get you an example on how your problem would be dealt with in 1.3 later tonight when I'm home from work.

Yeah, I know about the 1.3 interfaces for the listbox.and other controls. Now I wish Nifty 1.3 to be implemented ASAP in jME3 once it's gone "gold" ;)

Anyway. I asked knowing that it wasn't directly possible, but sometimes there's a way to get that information by a backdoor or an indirect way. I have tried that but there are so many people knowing a lot more than me that I thought maybe one would have found a solution.

Oh well. I guess I'll try to be patient. :)

ratoc, how bad of a headache is it to implement Nifty 1.3 in its current form in jME3? Would it be worth it? Or would it be preferable to be patient. It's not time-critical to have that working btw. No rush at all. It's just that I hate leaving stuff half-working.

getting nifty 1.3 to work in jme3 isn’t that hard

there’s just a few classes that need minor adjustments. Most of these can be found because they show up as compilation errors. There’s just one or two that are not so obvious.

If you really want I should be able to talk you through it.

Just contact me through msn, that’s easier than through the forums.


Now that most of the outstanding issues have been dealt with I have added you to my MSN.