2015-01-23 3 views
2

Раскладка как таковой:Есть ли более короткий способ написать этот экстракт FXML?

enter image description here

Что представляет интерес представляет верхняя часть окна; это 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:/

Я прошел через javadoc GridPane и не смог найти другой способ, чем то, что у меня есть сейчас, но я уверен, что этот другой, более короткий и удобный способ обслуживания.

Итак, что это за более короткий путь?

ответ

3

Попробуйте добавить VGap и HGap в команду Gridpane, вместо добавления Padding для каждого узла в нем.

hgapProperty - ширина горизонтальных промежутков между колоннами.

vgapProperty - высота вертикальных промежутков между рядами.

Смежные вопросы