I consider that improper behavior appears when Pane with insets contains another Pane.
Minimal code below
//////////////////////////////////////////
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class ShortApp extends Application {
public static void main(String[] args) {
Application.launch(ShortApp.class, args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World");
Pane mainContainer = new Pane();
mainContainer.setPrefSize(450, 350);
mainContainer.setPadding(new Insets(25));
HBox pane = new HBox();
pane.alignmentProperty().set(Pos.CENTER);
pane.setStyle("-fx-border-color: red;");
pane.setPrefSize(400, 300);
mainContainer.getChildren().add(pane);
primaryStage.setScene(new Scene(mainContainer));
primaryStage.setVisible(true);
}
}
/////////////////////////////////////////////////////
I awaited that inner pane will be located with insets from all four directions (top, bottom, left, right) of outer pane as written in docs.
But in fact pane glues to upper-left corner.
Minimal code below
//////////////////////////////////////////
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class ShortApp extends Application {
public static void main(String[] args) {
Application.launch(ShortApp.class, args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World");
Pane mainContainer = new Pane();
mainContainer.setPrefSize(450, 350);
mainContainer.setPadding(new Insets(25));
HBox pane = new HBox();
pane.alignmentProperty().set(Pos.CENTER);
pane.setStyle("-fx-border-color: red;");
pane.setPrefSize(400, 300);
mainContainer.getChildren().add(pane);
primaryStage.setScene(new Scene(mainContainer));
primaryStage.setVisible(true);
}
}
/////////////////////////////////////////////////////
I awaited that inner pane will be located with insets from all four directions (top, bottom, left, right) of outer pane as written in docs.
But in fact pane glues to upper-left corner.