खोज…


एक JList में चयनित तत्वों को संशोधित करें

जैसे एक JList दिया

JList myList = new JList(items);

सूची में चयनित आइटम के माध्यम से संशोधित किया जा सकता ListSelectionModel की JList :

ListSelectionModel sm = myList.getSelectionModel();  
sm.clearSelection();                      // clears the selection
sm.setSelectionInterval(index, index);    // Sets a selection interval
                                          // (single element, in this case)

वैकल्पिक रूप से, JList सीधे चयनित अनुक्रमित में हेरफेर करने के लिए कुछ सुविधाजनक तरीके प्रदान करता है:

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
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow