从组中选择单选按钮时会触发哪种 JavaFX2 事件,我该如何处理?
问问题
4948 次
1 回答
6
给定zodiacSigns
的是单选按钮所属的组,
zodiacSigns.selectedToggleProperty().addListener(new OnToggleHandler());
将事件处理程序OnToggleHandler
添加到按钮组(在 JavaFX 中称为切换组)。下面是代码OnToggleHandler
private class OnToggleHandler implements ChangeListener<Toggle> {
@Override
public void changed(ObservableValue<? extends Toggle> ov, Toggle t, Toggle t1) {
dailyHoro.editReading(((RadioButton) t1).getText());
dailyHoro.print();
System.out.println("Old: " + ((RadioButton) t).getText() + ", New: " + ((RadioButton) t1).getText());
if (dailyHoro.getText() == null)
textEditor.setText("");
else
textEditor.setText(dailyHoro.getText());
}
}
于 2013-10-23T14:24:28.727 回答