我似乎无法理解将ColorPicker值属性绑定到ScalaFX中的ObjectProperty的正确方法。这就是我到目前为止所做的:
private val colorProp = new ObjectProperty[Color](this, "test", Color.White)
// Create color picker
val cp: ColorPicker = new ColorPicker(Color.White) {
prefWidth = Prop.pickerWidth
}
colorProp <==> cp.value然而,我在这里得到了这个类型错误:
[error] (v: javafx.beans.property.Property[scalafx.scene.paint.Color])Unit <and>
[error] (v: scalafx.beans.property.Property[scalafx.scene.paint.Color,scalafx.scene.paint.Color])Unit
[error] cannot be applied to (scalafx.beans.property.ObjectProperty[javafx.scene.paint.Color])
[error] colorProp <==> cp.value我已经能够让像StringProperty这样的东西正常工作,但是当我尝试使用ObjectProperty时,这个问题就出现了。任何帮助都是最好的!
发布于 2018-06-18 01:49:27
结果,我需要使用JavaFX颜色而不是ScalaFX颜色。这对我来说仍然很奇怪,但它是有效的!不过,任何进一步的解释都会很好。
private val colorProp = new ObjectProperty[javafx.scene.paint.Color](this, "test", Color.White)https://stackoverflow.com/questions/50898482
复制相似问题