问题描述:

How do I make scala.swing.ListView only allow a single item to be selected at a time?

I want to disable the default behavior of allowing multiple items to be selected.

网友答案:

The most trivial way is to use peer property which is standard Swing JList:

listView.peer.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
网友答案:

I am using following (Scala 2.9.0-1):

import swing.ListView
import swing.ListView.IntervalMode

val listView: ListView[String] = new ListView[String](Seq("a", "b", "c")) {
  selection.intervalMode = IntervalMode.Single
}
相关阅读:
Top