布局如下:
感兴趣的是窗户的上半部分;它是GridPane
填充标签,我添加了填充,但是......
嗯,问题很明显:
<GridPane gridLinesVisible="false">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0" right="5.0"/>
</padding>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="SOMETIMES"/>
<ColumnConstraints hgrow="SOMETIMES"/>
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES"/>
</rowConstraints>
<!-- First column -->
<Label text="Date:" GridPane.rowIndex="0"
GridPane.columnIndex="0">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label fx:id="parseDate" GridPane.rowIndex="0"
GridPane.columnIndex="1">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label text="Total parse time:" GridPane.rowIndex="1"
GridPane.columnIndex="0">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label fx:id="totalParseTime" GridPane.rowIndex="1"
GridPane.columnIndex="1">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label text="Parse tree depth:" GridPane.rowIndex="2"
GridPane.columnIndex="0">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label fx:id="treeDepth" GridPane.rowIndex="2"
GridPane.columnIndex="1">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label text="Number of rules:" GridPane.rowIndex="3"
GridPane.columnIndex="2">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label fx:id="nrRules" GridPane.rowIndex="3"
GridPane.columnIndex="3">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<!-- Second column -->
<Label text="Total rule invocations:" GridPane.rowIndex="0"
GridPane.columnIndex="2">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label fx:id="totalInvocations" GridPane.rowIndex="0"
GridPane.columnIndex="3">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label text="Successful rules:" GridPane.rowIndex="1"
GridPane.columnIndex="2">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label fx:id="totalSuccess" GridPane.rowIndex="1"
GridPane.columnIndex="3">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label text="Global success rate:" GridPane.rowIndex="2"
GridPane.columnIndex="2">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
<Label fx:id="totalSuccessRate" GridPane.rowIndex="2"
GridPane.columnIndex="3">
<padding>
<Insets top="5.0" bottom="5.0" left="5.0"
right="5.0"/>
</padding>
</Label>
</GridPane>
为了实现我想要的目标,我必须为每个Label
添加填充:/ /
我已经走过了GridPane
的javadoc,找不到我现在的另一种方式,但我确信存在另一种更短,更可维护的方式。
那么,这个更短的方式是什么?