michael_s
michael_s

Reputation: 2575

JavaFX2 - Get the ImageView of an IO-Control

I'm using JavaFX2.2. Is it actually possible to get the ImageView used as a parameter in the constructor for an UI-control such as Button or Label after the UI-control has been created?

I want to change the image of a control. I could probably also do it with CSS, but I'm not sure of how to use jar-resources there.

Example:

Label label = new Label("", new ImageView(new Image(getClass().getResourceAsStream("test.png"))));
label.getImageView().setImage(...); // there is no such method getImageView()

Upvotes: 0

Views: 46

Answers (1)

Alexander Kirov
Alexander Kirov

Reputation: 3654

((ImageView) label.getGraphic()).setImage(...)

Upvotes: 1

Related Questions