こうですかね?
style="-fx-background-image: url(main/f.png);"
xml
1<?xml version="1.0" encoding="UTF-8"?>
2
3<?import javafx.scene.layout.BorderPane?>
4
5
6<BorderPane xmlns="http://javafx.com/javafx/11.0.1"
7 xmlns:fx="http://javafx.com/fxml/1"
8 style="-fx-background-image: url(main/f.png);"
9 fx:controller="ctrl.Control"/>
Correct way to set the path of a BackgroundImage in JavaFX CSS - Stack Overflow
追記 全文
Java
1package main;
2
3import javafx.application.Application;
4import javafx.fxml.FXMLLoader;
5import javafx.scene.Parent;
6import javafx.scene.Scene;
7import javafx.stage.Stage;
8
9public class Main extends Application {
10 public static void main(String[] args) { launch(args); }
11
12 @Override public void start(Stage primaryStage) throws Exception {
13 Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
14 primaryStage.setTitle("Hello World");
15 primaryStage.setScene(new Scene(root, 300, 275));
16 primaryStage.show();
17 }
18}
xml
1<?xml version="1.0" encoding="UTF-8"?>
2
3<?import javafx.scene.layout.BorderPane?>
4
5
6<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
7 prefHeight="400.0" prefWidth="600.0"
8 style="-fx-background-image: url(main/f.png);"
9 xmlns="http://javafx.com/javafx/11.0.1"
10 xmlns:fx="http://javafx.com/fxml/1"
11 fx:controller="ctrl.Control"/>
Java
1package ctrl;
2
3public class Control {}