I suppose it\'s a very simple thing but I just can\'t get behind it. All I want is to show an image over an ImageView linked to fxml. Here is my code:
packag
If you want to use FXML, you should separate the controller (like you were doing with the SampleController). Then your fx:controller in your FXML should point to that.
Probably you are missing the initialize method in your controller, which is part of the Initializable interface. This method is called after the FXML is loaded, so I recommend you to set your image there.
Your SampleController class must be something like this:
public class SampleController implements Initializable {
@FXML
private ImageView imageView;
@Override
public void initialize(URL location, ResourceBundle resources) {
File file = new File("src/Box13.jpg");
Image image = new Image(file.toURI().toString());
imageView.setImage(image);
}
}
I tested here and it's working.