Saturday, November 22, 2014

JList: control over selection

Control over selection in list items is possible through three constants defined in ListSelectionModel.interface.
1. SINGLE_SELECTION
    This constant is used if we want to restrict the selection to at most one item.
2. SINGLE_INTERVAL_SELECTION
    This constant is used if we want to select the items in regular way, i mean in sequential way. So we can't select item at first position  and an item at 4th position. We have to use shift key to select more then one item.
3. MULTIPLE_INTERVAL_SELECTION
    This is the default selection mode for JList instance. In this case we can select items also with multiple interval, i.e. by pressing control key, we can do random selection of items, however both of the above is also applicable. View in details here


If want to know about how to use JList in swing application click here.

No comments:

Post a Comment