A cél egy háttérkép elhelyezése a Pane konténeren.
Csak PNG állománnyal működik.
A kép helye a projekt gyökérkönyvtára.
Image image = new Image("file:kepfajlnev.png"); BackgroundSize backgroundSize = new BackgroundSize(100, 100, true, true, true, false); BackgroundImage backgroundImage = new BackgroundImage(image, null, null, null, backgroundSize); Background background = new Background(backgroundImage); pane.setBackground(background);
Automatikus méret:
BackgroundSize backgroundSize = new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, true, true, true, true);
A képfájl helye az src/resources/com/example/ könyvtár.
#pane { -fx-background-image: url("images/tatra_hegy.png"); -fx-background-repeat: no-repeat; -fx-background-position: center; -fx-background-size: cover; }