CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2001

    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

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    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)
    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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.