0

I'm trying to get the example code (HelloScalaFX) on http://www.scalafx.org/ to run. However, the line

        fill <== when (hover) choose Color.Green 
                          otherwise Color.Red

give me the error

        overloaded method value <== with alternatives: (v:
     scalafx.beans.value.ObservableValue[_ <:
     javafx.scene.paint.Paint, _ <: javafx.scene.paint.Paint])Unit <and> (v:
     javafx.beans.value.ObservableValue[_ <: javafx.scene.paint.Paint])Unit cannot be applied to
 (scalafx.Includes.ObjectConditionBuilder[javafx.scene.paint.Color])

If I delete the offending lines, I get no compile errors, but running it gives:

Error: Could not find or load main class HelloStageDemo

How do I resolve the overloading and get this to work?

OSX 10.11.5
JavaSE-1.8
Scala IDE build of Eclipse SDK (4.3.0)
Scala Library container 2.11.8
scalafx_2.12.0-M4-8.0.92-R10.jar

Thanks, Dave

David Matuszek
  • 1,263
  • 1
  • 16
  • 30
  • Your title should reflect the problem. "Trying again to learn ScalaFX" doesn't reflect the problem; it'd be no different to naming it "I just had a coffee". – James Donnelly Jun 01 '16 at 15:32
  • Fair enough. Maybe it should be "Can't get first example ScalaFX program to work." – David Matuszek Jun 01 '16 at 15:46
  • Beside line break mentioned in the answer below, there is something in code or setup that is not included in the question. Please provide [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Jarek Jun 01 '16 at 23:57
  • Another thing that seems fishy to my is the mention of `Scala Library container 2.11.8` and `scalafx_2.12.0-M4-xxxxx.jar`: seems like it should be `scalafx_2.11-xxxxx.jar`, to be compatible with Scala 2.11.x. – Cyäegha Jun 02 '16 at 13:26
  • Yes, that was fishy. Since the Scala IDE only uses 2.11, I expected Scala 2.11 to be compatible with the newer scalafx 2.12, but it isn't. Using scalafx_2.11 fixes one of the problems. – David Matuszek Jun 02 '16 at 14:01

1 Answers1

1

First, there should be no line break before otherwise, that code would not compile in Scala. It should be:

fill <== when (hover) choose Color.Green otherwise Color.Red

There was a break on the http://www.scalafx.org/ due to page layout, it is now corrected.

The second error, "Could not find or load main class", is not ScalaFX or JavaFX related but probably something with your code that you did not include in the question or with Eclipse setup.

Jarek
  • 1,513
  • 9
  • 16
  • Thanks! As I'm unfamiliar with "fill <==", the syntax looked OK to me. That (along with dropping back to scalafx 2.11) fixes everything, and I can now begin to explore scalafx! – David Matuszek Jun 02 '16 at 14:01