lazy val ui = new FlowPanel { val listView = new ListView( Seq("spam", "eggs", "ham") ) listenTo(listView.selection) reactions += { case SelectionChanged(`listView`) => println(listView.selection.items(0)) } contents += listView }
This should produce a result, e.g.
spam spam eggs eggs ham ham
when you click on various items. I have never done this before, but I looked at the UIDemo
example, which can be found in the scala.swing.test
package. To read the source, if you have IntelliJ, it is as simple as clicking on the corresponding object in scala -swing.jar in the external libraries in the Projects panel.
As for PopupMenu, I don't know - it looks like it doesn't have a scala -swing wrapper in 2.9.1, but I found it on GitHub. Or you can just use the regular version of Swing.
source share