I have a ImageView with a transparent image (PNG) therefore the image doesn't fill the complete rectangle of the image view, when mouse hover over the image view I want to change the background color of only the rectangle of the image view. In Css how I do it? do the image view node have the property -fx-background color? I tried and it's doesn't work for me. I have a css file linked to the .FXML
Asked
Active
Viewed 4,592 times
2
-
2Put the image view in a `StackPane` and use `-fx-background-color` on the `StackPane`. – James_D Oct 15 '15 at 13:32
-
2`-fx-background-color`,is a property of `Region.`. So, `image view` doesn't have this property. – Kachna Oct 15 '15 at 13:32
-
thanks! that worked very well – Sredny M Casanova Oct 15 '15 at 17:01
1 Answers
0
Use this
Bounds bound = ImageView.getBoundsInLocal(); //getting co-ordinates
ImageView.setEffect(ColorInput(bound.getMinX(), bound.getMinY(),
bound.getWidth(), bound.getHeight(), Color.YELLOW));
By function should work.

Elltz
- 10,730
- 4
- 31
- 59
-
1this just painted the color OVER my ImageView and now I can't see the image. – nhouser9 Oct 14 '17 at 17:48