Reputation: 696
I am trying to import the Color
class from javafx
, and use it in a scala class.
But when I use my class somewhere else, I get this error:
Error:(9, 50) type mismatch;
found : javafx.scene.paint.Color
required: drawingengine.Color
Here is the code:
package drawingengine
import javafx.scene.paint.Color
sealed class Pixel(x: Int, y: Int, color: Color);
I can fix it myself by changing line 3 to:
sealed class Pixel(x: Int, y: Int, color: javafx.scene.paint.Color);
But I think this is kinda ugly, so is't there a better way to use an imported class?
Also, i get this warning
imported `Color' is permanently hidden by definition of object Color in package drawingengine
import javafx.scene.paint.Color
and IntelliJ greys out the importing line as if it is not used.
I can see that others have had the same problem, but I don't see how the shown example applies to what i am doing. So what can I do about this warning?
Upvotes: 0
Views: 64
Reputation: 21104
This means you have defined your own Color
class, inside the same package drawingengine
, and that it is colliding with the JavaFX one.
This
javafx.scene.paint.Color
fixes it because you explicitly use a qualified name.
If you want to maintain both of them, you might alias the JavaFX one
import javafx.scene.paint.{Color => FxColor}
And use it like
sealed class Pixel(x: Int, y: Int, color: FxColor);
Upvotes: 2