this is the preview in scene builder
below is the fxml code
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="452.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1">
<center>
<ImageView fitHeight="187.0" fitWidth="372.0" pickOnBounds="true" preserveRatio="true" BorderPane.alignment="CENTER">
<image>
<Image url="@../../../../java/testImages/testImage.jpeg" />
</image>
</ImageView>
</center>
<bottom>
<Button mnemonicParsing="false" text="Button" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>
the image below is the executed code result where the image should appear
below is the java code
package com.ultijavafx.ultijavafx;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class jfx extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(jfx.class.getResource("javafxVeiw.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 1500, 1000);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
the image below is the resource structure