I am having trouble creating a ButtonGroup containing radio buttons in the Scala Programming Language. The code I am using is as following:
val buttongroup = new ButtonGroup {
buttons += new RadioButton("One")
buttons += new RadioButton("Two")
}
and my code for displaying the button group is within a BorderPanel:
layout += new BoxPanel(Orientation.Vertical) {
buttongroup
} -> BorderPanel.Position.West
However, nothing displays... I've consulted the API and I'm not sure what is wrong!!
You should add a list containing the buttons to the panel, not the buttongroup itself, e.g.:
val radios = List(new RadioButton("One"), new RadioButton("two"))
layout += new BoxPanel(Orientation.Vertical) {
contents ++= radios
}
See also this example in the scala swing package itself.