我有一个很多控件(标签,Textfields,Comboboxes和复选框)的GUI。我将它们组织在一个Gridpane中,并希望将它们放在行和列中(例如,它是用于Gridpane布局的)。JavaFX:使用FXML在行(在gridpane中)组织控件
如果我使用FXML我写这样的:
<GridPane>
<Label GridPane.rowIndex="0" GridPane.columnIndex="0" text="field1"/>
<TextField GridPane.rowIndex="0" GridPane.columnIndex="1"/>
<Label GridPane.rowIndex="1" GridPane.columnIndex="0" text="field2"/>
<TextField GridPane.rowIndex="1" GridPane.columnIndex="1"/>
</GridPane>
现在的问题:如果我想补充行0和1之间的行,我需要增加以下行的行索引。现在让我们取20行和5列,我想在第一行之后添加一行。这对我来说会增加低于第一行的每行的排行数。
有没有像行元素一样,它的子控件在同一行中的位置随着列数的增加而变化?我觉得是这样的:
<GridPane>
<GridPane.Row>
<Label text="field1"/>
<TextField/>
</GridPane.Row>
<GridPane.Row>
<Label text="field2"/>
<TextField/>
</GridPane.Row>
</GridPane>
我知道垂直框中,然后HBox中,这几乎是我想要的,但我想在列的元素固定宽度。
虽然我没有回答你的问题,你有没有考虑过使用'SceneBuilder'? –
感谢您的建议。事实上,我已经尝试过,但发现它太慢了很多元素。另外,处理有时非常困难。但是,不幸的是我停止了任何JavaFX开发,可能会帮助重新编号行 – user1571117