0
我想要獲得一個背景圖像加載到一個javaFX場景。我在這裏找到的答案是行不通的。窗口打開,但它是空白的(沒有圖像)。JavaFX中的背景圖像
public class FirstFX extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
StackPane root = new StackPane();
BackgroundImage myBI= new BackgroundImage(new Image("SnLBoard.png"),
BackgroundRepeat.REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
root.setBackground(new Background(myBI));
stage.show();
}
}
工作正常!謝謝。 –