swing
JList
Buscar..
Modificar los elementos seleccionados en un JList.
Dado un JList
como
JList myList = new JList(items);
los elementos seleccionados en la lista se pueden modificar a través de ListSelectionModel
de JList
:
ListSelectionModel sm = myList.getSelectionModel();
sm.clearSelection(); // clears the selection
sm.setSelectionInterval(index, index); // Sets a selection interval
// (single element, in this case)
Alternativamente, JList
también proporciona algunos métodos convenientes para manipular directamente los índices seleccionados:
myList.setSelectionIndex(index); // sets one selected index
// could be used to define the Default Selection
myList.setSelectedIndices(arrayOfIndexes); // sets all indexes contained in
// the array as selected
Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow