我正在尝试使用包含2行和2列的gridpane设计布局.左上角区域和右上角区域共享宽度,它们都占50%.但在第二排我需要右下方区域才能获得60%的宽度,因此左下区域为40%.
我也尝试过像[[2col.,2col] [1col,3col]]矩阵那样的柱子.它既不起作用也不起作用.
这是我的代码;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Group root = new Group();
primaryStage.setTitle("Hello World");
Scene scene = new Scene(root, 1700, 1200);
//zoneTopLeft, spans 2 column
VBox zoneTopLeft = createBaseContainer();
//zoneTopRight, spans 2 columns
VBox zoneTopRight = createBaseContainer();
//zoneBottomLeft, spans 1 columns
VBox zoneBottomLeft = createBaseContainer();
//zoneBottomRight,spans 3 columns
VBox zoneBottomRight = createBaseContainer();
ColumnConstraints topRight=new ColumnConstraints();
topRight.setPrefWidth(300);
ColumnConstraints topLeft=new ColumnConstraints();
topRight.setPrefWidth(300);
ColumnConstraints bottomRight=new ColumnConstraints();
topRight.setPrefWidth(400);
ColumnConstraints bottomLeft=new ColumnConstraints();
topRight.setPrefWidth(200);
GridPane …Run Code Online (Sandbox Code Playgroud)