May 13th, 2003, 10:34 AM
multiple selection in Jlist
I have a JList whose data is set by setListData(Object  ) method.
Now if i have another object  say arr2 so that i have to select those items and to keep the selection in the JList how to do that.??
I have seen the method JList.setSelectedValue(object, true);
method but then it takes a single object and if i traverse arr2 and select each element separately selection event is fired each time and moreover only the last object remans as selected(obviuous i guess).
So how to select those object in the JList.
Thanks in advance
May 14th, 2003, 07:08 AM
Did you read the JList JavaDocs?
If you can't find a way to get the selection you want using JList directly, use the ListSelectionModel, which (unless you've changed it) you can cast to an instance of DefaultListSelectionModel.
By default the JList selection model allows any combination of items to be selected at a time, using the constant MULTIPLE_INTERVAL_SELECTION. The selection state is actually managed by a separate delegate object, an instance of ListSelectionModel. However JList provides convenient properties for managing the selection.
Quemadmodum gladius neminem occidit, occidentis telum est...
(paraphrase: Swords don't kill people, people kill people)
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!