Reputation: 13004
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.
Upvotes: 2
Views: 885
Reputation: 1756
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
}
Upvotes: 2
Reputation: 17369
The most trivial way is to use peer
property which is standard Swing JList
:
listView.peer.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
Upvotes: 2