1
votes

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

1
Put the image view in a StackPane and use -fx-background-color on the StackPane.James_D
-fx-background-color,is a property of Region.. So, image view doesn't have this property.Kachna
thanks! that worked very wellSredny M Casanova

1 Answers

1
votes

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.