I am trying to implement a simple application in which I can write an item in Textfield and then entering a button which in turn reacting by inserting that item in a combo box.
However, I am facing a problem that the scala combobox swing is not mutable(I guess)?
Is there any way to make a combo mutable using scala swing?
import scala.swing._
import scala.swing.event._
import scala.swing.BorderPanel.Position._
object ReactiveSwingApp extends SimpleSwingApplication {
def top = new MainFrame {
title = "Reactive Swing App"
val button = new Button {
text = "Add item"
}
var textfield = new TextField {
text = "Hello from a TextField"
}
var items = List("Item 1","Item 2","Item 3","Item 4")
val combo = new ComboBox(items)
contents = new BorderPanel {
layout(new BoxPanel(Orientation.Vertical) {
contents += textfield
contents += button
contents += combo
border = Swing.EmptyBorder(30, 30, 10, 30)
}) = BorderPanel.Center
}
listenTo(button, textfield)
reactions += {
case ButtonClicked(button) =>
// var items1 = textfield.text :: items <- how can a read Item be inserted
}
}
}