multiple selection in Jlist
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: multiple selection in Jlist

  1. #1
    Join Date
    Sep 2001
    Location
    Bangalore
    Posts
    98

    multiple selection in Jlist

    Hi,

    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

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163
    Did you read the JList JavaDocs?
    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.
    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.

    Quemadmodum gladius neminem occidit, occidentis telum est...
    (paraphrase: Swords don't kill people, people kill people)
    Seneca
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center