There is not much Japanese documentation on JavaFX, so I will summarize it.
FXML editing may or may not use SceneBuilder.
| Type | version |
|---|---|
| OS | Windows10 64bit |
| IntelliJ IDEA | 2017.1.5 |
| JDK | 1.8.0_121 |
The following is an example of creating a 2x2 Grid.
2x2 Grid Pane example
<GridPane gridLinesVisible="true" hgap="10" vgap="10" xmlns="http://javafx.com/javafx/8.0.112"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
<columnConstraints>
<ColumnConstraints/>
<ColumnConstraints/>
</columnConstraints>
<rowConstraints>
<RowConstraints/>
<RowConstraints/>
</rowConstraints>
</GridPane>
You can extend the grid by adding child elements inside columnConstraints, rowConstraints. It seems that this is not much different from the WPF Grid specifications.
Control assignment
<GridPane alignment="center" hgap="10" vgap="10" xmlns:fx="http://javafx.com/fxml/1"
xmlns="http://javafx.com/javafx/8.0.112" fx:controller="sample.Controller">
<rowConstraints>
<RowConstraints/>
<RowConstraints/>
</rowConstraints>
<columnConstraints>
<ColumnConstraints/>
<ColumnConstraints/>
</columnConstraints>
<children>
<Label text="Label" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
</children>
</GridPane>
<children> tag is optional, and the control may be located directly under GridPane.python
<GridPane hgap="10" vgap="10" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
<rowConstraints>
<RowConstraints percentHeight="100" />
</rowConstraints>
<columnConstraints>
<ColumnConstraints percentWidth="50" />
<ColumnConstraints percentWidth="50"/>
</columnConstraints>
<children>
<TextArea prefHeight="200.0" prefWidth="200.0" />
<TextArea prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" />
</children>
</GridPane>
You can set a percentage for each element.

todo: What happens when the size specification and the percentage specification are combined?
java - JavaFX - Get GridPane to fit parent - Stack Overflow
It seems easy to add from the right-click menu on the left menu.

Recommended Posts