problem with jList and setSelectedValue
843807May 11 2010 — edited May 12 2010Hi,
I have quite a long list of strings which I put in a jList (which I name jListRef). I want to select a specific item in this list and I want the list to scroll so that this selected item becomes visible. I tried this code :
jListRef.setSelectedIndex(c);
boolean scrollInView = true;
jListRef.setSelectedValue(jListRef.getSelectedValue(), scrollInView);
and it doesn't work. The relevant item of the list is selected, but the list does not scroll, so the selected item remains hidden, I have to scroll the list manually to make it appear.
My jList is filled with strings, so I also tried this code :
jListRef.setSelectedIndex(c);
boolean scrollInView = true;
jListRef.setSelectedValue(jListRef.getSelectedValue().*toString()*, scrollInView);
it doesn't work either (same behaviour as the upper code).
The setSelectedValue(o1,b1) method of the jList is supposed to scroll the list to the item o1 if b1 is true, so I don't get what i'm doing wrong. I just know it doesn't work.
Any help is welcome.
TIA