I have some issue with switch scenes at JavaFX. I have the primary stage that I set to him the first scene with background number 1:
then I switch to the new scene and I get this screen:
how can I resize my new CSS to cover the all screen?
I tried to set the background into my new scene but as you see that result above
css of second background:
.grass{
-fx-background-image:url("/images/25474739-closeup-image-of-natural-
green-grass-soccer-field.jpg");
-fx-background-repeat:stretch,stretch;
-fx-background-size:cover;
-fx-background-position: center center;
}
css of first one:
.root {
-fx-background-image: url("/images/menu.jpg");
-fx-background-size:cover;
-fx-background-position: center center;
}
the function that i change the scenes:
public void switchMain(String string , AnchorPane container,String css) {
try {
FXMLLoader fxmlLoader = new FXMLLoader();
AnchorPane root =
fxmlLoader.load(getClass().getResource("GameScreen.fxml").openStream());
container.getChildren().setAll(root);
if(!css.equals("")) {
myStage.getScene().getStylesheets().add(getClass().getResource
("MazeDisplyGra
ss.css").toExternalForm());
}
} catch (IOException e){
}
I am not have any idea how to solve it. so please, if you get some good solution , share it with me : )