dsg
dsg

Reputation: 13004

scala.swing.ListView: single/multiple selection

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

Answers (2)

ygor
ygor

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

Eugene Ryzhikov
Eugene Ryzhikov

Reputation: 17369

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

listView.peer.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)

Upvotes: 2

Related Questions