0

Say I have the following code:

import scalafx.beans.property.ObjectProperty
import scalafx.scene.image.Image

def foo(property: ObjectProperty[Image]) = {...}

Then somewhere else I have an image view who's imageProperty I want to pass to the function:

import scalafx.scene.image.ImageView

val view: ImageView
...
val property = view.image
foo(property) // will not compile

This will not compile as the property returned from image is a javafx..Image as opposed to scalafx.

Is it sufficient to do

foo(property.asInstanceOf[ObjectProperty[Image]])

or is there a better way of converting?

user79074
  • 4,937
  • 5
  • 29
  • 57

1 Answers1

1

The only way I got it to work was with an explicit call to delegate. Something like the following:

import scalafx.beans.property.ObjectProperty
import scalafx.scene.image.Image

def foo(property: ObjectProperty[jfxsi.Image]) = {
...
  val image: Image
  ...
  property.set(image.delegate) 
}
user79074
  • 4,937
  • 5
  • 29
  • 57