0
我正在使用JavaFX。我有一個包括設計configuration.I需要編寫同樣作爲FXML文件中的Java文件,即Java的FX allows.For如:Java fx fxml代
GridPane gridPane = new GridPane();
Label label = new Label();
label.setText("My Label");
GridPane.setRowIndex(label, 0);
GridPane.setColumnIndex(label, 0);
gridPane.getChildren().add(label);
的FXML當量是:
<GridPane>
<children>
<Label text="My Label">
<GridPane.rowIndex>0</GridPane.rowIndex>
<GridPane.columnIndex>0</GridPane.columnIndex>
</Label>
</children>
</TabPane>.
現在我使用多個佈局,比如vbox,hbox和gridpane.how,我可以爲它生成fxml嗎?下面給出Java代碼。請幫助生成它的fxml。
VBox vBox = new VBox();
vBox.setSpacing(10);
vBox.setPadding(new Insets(60, 0, 0, 20));
vBox.setAlignment(Pos.TOP_CENTER);
HBox hbox= new HBox();
hbox.setPadding(new Insets(1,0,0,770));
hbox.setSpacing(2);
hbox.setAlignment(Pos.CENTER);
GridPane homegrid = new GridPane();
homegrid.setPadding(new Insets(100, 100, 90, 50));
homegrid.setVgap(5);
homegrid.setHgap(5);
Button employee = new Button("");
employee.setUserData(Font.BOLD);
employee.setMinSize(100, 100);
homegrid.setConstraints(employee, 10,10);
homegrid.getChildren().addAll(employee,shop,product,datamanager,leave,users);
rootGroup.getChildren().addAll(vb);
rootGroup.getChildren().addAll(homegrid,hbox);