How to center a node within a pane javafx
问题 How do I create a Pane and have a child Node put at the center? Lets say the Pane is 500 by 500 and the Node is an ImageView with a 200 by 200 Image ImageView view = new ImageView(); Image img = new Image("test.png"); view.setImage(img); Pane pane = new Pane(); pane.setMinWidth(500); pane.setMinHeight(500); pane.getChildren().add(view); 回答1: you have 2 choices : For example using StackPane instead of Pane (because you can use Pos) StackPane p = new StackPane(); p.setPrefSize(700,700); //set a