1

I'm trying to add a background image to my JavaFX 3D program, but it just translates the ImageView instead of setting it as the background. What am I missing?

I create the ImageView, and then add it to a separate Group object in the start method. The choiceLayout is another Group object.

Image image = new Image(Program.class.getResourceAsStream("picture.jpg"));
ImageView view = new ImageView(image);
view.setPreserveRatio(true);
view.getTransforms().add(new Translate(-image.getWidth() / 2, -image.getHeight() / 2, 800));
Group bg = new Group();
bg.getChildren().add(choiceLayout); 
bg.getChildren().add(view);

Scene choiceScene = new Scene(bg, 1024, 768, true);
    

0 Answers0