swing
JList
サーチ…
JListで選択した要素を変更する
JList
ようなもの
JList myList = new JList(items);
リスト内の選択された項目は、 JList
ListSelectionModel
によって変更できます。
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