You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For instance, if an ObjectProperty has parameter type scalafx.scene.paint.Color it cannot be bound to fill property in scalafx.scene.shape.Rectangle.
You will get compilation error:
error: overloaded method value <== with alternatives:
(v: scalafx.beans.value.ObservableValue[_ <: javafx.scene.paint.Paint, _ <: javafx.scene.paint.Paint])Unit
(v: javafx.beans.value.ObservableValue[_ <: javafx.scene.paint.Paint])Unit
cannot be applied to (scalafx.beans.property.ObjectProperty[scalafx.scene.paint.Paint])
fill <== fillPaint
This issue could not be easily and completely fixed without significant changes to ScalaFX code base. To make it easier to deal with it I implemented factory methods for ObjectProperty that simplify the work around (using ObjectProperty with JavaFX value type) https://code.google.com/p/scalafx/source/detail?r=bb04f99df3c7ebf13779bc7c3ce4f5f2a102da5d The work around is to use a factory method, rather than constructor. The factory method with create ObjectProperty with correct value type. When using it, do not specify type of created instance, let the Scala compiler infer it. For instance, instead of using constructor:
Removed imports of JavaFX classes where possible.
Type parameters need to be JavaFX types, so left them but used alises as in the rest of ScalaFX code -
see issue #14 and #142.
Hi, sorry for digging up that old thread,
I wonder if there is/was any progress on this? Or a known/recommended workaround?
I tried the factory method approach, but that leaves me with NPEs, this is on 8.0.102-R11.
Thanks!
From galic...@gmail.com on December 13, 2012 23:23:15
For instance, if an
ObjectProperty
has parameter typescalafx.scene.paint.Color
it cannot be bound tofill
property inscalafx.scene.shape.Rectangle
.You will get compilation error:
error: overloaded method value <== with alternatives:
(v: scalafx.beans.value.ObservableValue[_ <: javafx.scene.paint.Paint, _ <: javafx.scene.paint.Paint])Unit
(v: javafx.beans.value.ObservableValue[_ <: javafx.scene.paint.Paint])Unit
cannot be applied to (scalafx.beans.property.ObjectProperty[scalafx.scene.paint.Paint])
fill <== fillPaint
Example code illustrating that is here: https://github.com/jsacha/ProScalaFX/blob/master/test/src/misc/ChangeFillExample.scala (also attached)
Also, if you look at implementation of
scalafx.scene.Node
you can see that ObjectProperty types there, they use JavaFX types for value. https://code.google.com/p/scalafx/source/browse/src/scalafx/scene/Node.scala#65 I think this is because of the same binding problem.Attachment: ChangeFillExample.scala
Original issue: http://code.google.com/p/scalafx/issues/detail?id=14
The text was updated successfully, but these errors were encountered: