有没有更短的方法来编写这个 FXML 摘录?
Is there a shorter way to write this FXML extract?
布局是这样的:
感兴趣的是 window 的上半部分;它是一个 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,找不到比我现在拥有的方法更好的方法,但我确信存在其他更短且更易于维护的方法。
那么,这条更短的路是什么?
布局是这样的:
感兴趣的是 window 的上半部分;它是一个 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,找不到比我现在拥有的方法更好的方法,但我确信存在其他更短且更易于维护的方法。
那么,这条更短的路是什么?