// The default mode is MULTIPLE_INTERVAL_SELECTION
String[] items = {"A", "B", "C", "D"};
JList list = new JList(items);
// Get the current selection model mode
int mode = list.getSelectionMode(); // MULTIPLE_INTERVAL_SELECTION
// Only one item can be selected
list.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
// The selected items must be in a contiguous range
list.setSelectionMode(DefaultListSelectionModel.SINGLE_INTERVAL_SELECTION);
// Multiple ranges of selected items are allowed
list.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION);