我如何收听scala中单选按钮上的事件?我有以下代码,但由于某种原因没有执行反应。这是一个对话框,我正在寻找单选按钮选择,并相应地更改对话框窗口的标题。
val dirFileSelector = {
List(
new RadioButton("Directory"){
name = "dir"
},
new RadioButton("File"){
name = "file"
}
)
}
val buttonGroup = new ButtonGroup
dirFileSelector map { button=>
listenTo(button)
buttonGroup.buttons.add(button)
}
contents = new BorderPanel{
add(new BoxPanel(Orientation.Horizontal) {contents ++= dirFileSelector}, BorderPanel.Position.North)
}
reactions += {
case SelectionChanged(buttonSelect) => {
println("buttonSelect selection changed")
buttonSelect.name match {
case "dir" => title = "Add Directory"
case "file" => title = "Add File"
}
}
}