- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写一个代码,它可以从其他代码的一部分中获取一些 bool 值,并相应地改变屏幕上某些圆圈的颜色。但是,我在尝试将 bool 值绑定(bind)到颜色时遇到了问题。我最终得到了这个:
unit1.getNeuron().getWorkingProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if (newValue == Boolean.FALSE) {
controller.paint1 = new ObservableValueBase<Paint>() {
@Override
public Paint getValue() {
return Color.RED;
}
};
} else {
controller.paint1 = new ObservableValueBase<Paint>() {
@Override
public Paint getValue() {
return Color.DODGERBLUE;
}
};
}
}
});
最佳答案
假设您要创建一个 ObservableObjectValue<Paint>
你想根据 ObservableBooleanValue
切换, 然后 Bindings
是你的 friend :
final ObservableBooleanValue booleanCondition = unit1.getNeuron().getWorkingProperty();
final ObservableObjectValue<Paint> paintProperty = Bindings.when(booleanCondition).then(Color.RED).otherwise(Color.DODGERBLUE);
关于binding - JavaFX 将 BooleanProperty 绑定(bind)到 Paint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29672418/
我正在为 JavaFX 开发一个幻灯片菜单,在它的定义中,我不断地使用 getScene() 方法来引用节点所在场景的高度和宽度已添加。 问题是幻灯片菜单在场景定义之前定义,返回 NullPointe
我正在尝试将 JavaFX BooleanPropety 添加到由 Hibernate 保留的模型中,但出现以下错误。 Caused by: org.hibernate.MappingExceptio
我喜欢使用属性类,但我不喜欢用多长的句子来做简单的事情。 我想扩展 SimpleBooleanProperty 类,这样就不需要做这样的事情: myProperty.setValue(!myPrope
我有两个 ToggleButton,我希望它们都绑定(bind)到一个 boolean 属性,这样当一个 ToggleButton 被选中时,另一个 ToggleButton 不会被选中,并且 Boo
我正在编写一个代码,它可以从其他代码的一部分中获取一些 bool 值,并相应地改变屏幕上某些圆圈的颜色。但是,我在尝试将 bool 值绑定(bind)到颜色时遇到了问题。我最终得到了这个: unit1
我是一名优秀的程序员,十分优秀!