【发布时间】:2016-12-26 10:09:19
【问题描述】:
我有 3 个ToggleGroups,我需要将其附加到TextField,以便TextField 每次ToggleGroup 属性更改时显示适当的数字。
首先,我为每个 ToggleGroup 添加了一个监听器
int f; //to calculate the first property condition
group1.selectedToggleProperty().addListener((v, oldValue, newValue) -> {
if (group1.getSelectedToggle() != null) {
//call a method which test the radioButtons to give the value to each one
f = testChoix(rdF1, rdF2, rdF3, rdF4);
}
});
然后我添加了一个监听器到TextField
txtCriticite.textProperty().addListener((observable, oldValue, newValue) -> {
calculCriticite();//method to calculate
});
//method to calculate the textField Value
public void calculCriticite() {
int c = f * g * d;
txtCriticite.setText(String.valueOf(c));
}
编译并单击RadioButtons 时,我的TextField 中没有看到任何文字
【问题讨论】:
标签: javafx