I have a problem loading images from ImageView to FXML.
My controller class:
public class BoxViewController { @FXML private Label label_boxID; @FXML private ImageView boximage; public void initData(ObservableList<BoxProperty> observableList, BoxService sBox, TableView tableview) { this.label_boxID.setText( String.valueOf(this.boxproperty.getPboxid())); Image image = new Image("boximage.jpg"); this.boximage = new ImageView(); this.boximage.setImage(image); } }
So, setting a shortcut with text works, but the image will not appear in my ImageView. For ImageView, I added an ID to the FXML file:
<ImageView fx:id="boximage" disable="false" fitHeight="150.0" fitWidth="200.0" layoutX="69.0" layoutY="322.0" pickOnBounds="true" preserveRatio="true" />
I am confused why this does not work, because the shortcut works, but the image does not load.
I also checked if boximage nonempty, but it is not. There are also no exceptions.
source share