How do I get buttons to fill a javafx gridpane?

前端 未结 3 1458
伪装坚强ぢ
伪装坚强ぢ 2021-02-15 09:24

Java Swing has GridLayout, which allows you to specify a size for an array of widgets such as 3X4. The widgets then fill the panel they occupy. How do you get a s

3条回答
  •  眼角桃花
    2021-02-15 10:13

    You can use a GridPane in JavaFX for that. In Java-Code, you can create it by

    GridPane pane = new GridPane();
    

    and add different nodes to it, for example like

    Label label = new Label();
    pane.add(label, 0,0);
    

    This will add a label to the first row and the first column of the GridPane. For more complex GUIs, you could use the SceneBuilder.

提交回复
热议问题