JList bean, setSelectedIndex method

hi everybody,

I would like to ask about using bean in my servoy solution.

I used JList Bean for selection values.

In my program there are 2 list, 1 at the left side and next at the right side.

i want to select a value from left side list bean and click add button , then the value should move from left side list bean to right side list bean.

in my case, i can move value from left side to right side.

but for my value, i need to reselect the value and click add button again.

my problem, is i don’t want to re-select the value in left side list bean.

it should automactically select the top most value once i click the add button.

how to select the top most value in list bean?

i think setSelectedIndex(index) should work well, but in my solution it is not working well.

Thanks indeep

Dennis

hi all,

I also would like to get maximum index value from Jlist bean.

thanks

Dennis

how to select the top most value in list bean?

elements.myList.selectedIndex = 0;

Are you interacting with the list’s model property?
…or are you calling setListData()?

Using the model will give you greater control.
I suggest learning the DefaultListModel class. It is part of the Java Swing library.

When your form loads, you’ll want to add:

elements.myList.model = new Packages.javax.swing.DefaultListModel();

After that, you will be able to interact with your list more easily via the model. Check out the methods available for this class at:

http://java.sun.com/j2se/1.4.2/docs/api … Model.html

Hope this Helps.