I would like to set a background image the same size as my window/screen.
I would prefer to do this in my CSS file, but I have NOT FOUND a way to accomplish this.
Must I do this in a javafx class file?
Thanks for every help ;)
解决方案
You will have to determine the screen size in java code as demonstrated in JavaFX window sizing, there is no way to determine it in CSS.
For an Image, in your java code you can use something as
ImageView imageView = new ImageView(image);
imageView.setFitWidth(Screen.getPrimary().getVisualBounds().getWidth());
imageView.setFitHeight(Screen.getPrimary().getVisualBounds().getHeight());
If you want to set the background image to a scene then:
import javafx.application.Application;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javaf