1
我試圖讓我的TextFill在HBox內自動調整大小。要做到這一點使用sceneBuild或FXML代碼它很簡單隻需設置HGrow屬性在畫面波紋管送花兒給人這樣的:如何動態設置HGrow屬性?
但對於一些原因,我不得不在Java代碼中動態生成我的組件和這樣我找不到如何將此屬性設置爲我的textField。
HBox hBox = new HBox();
TextField autoCompleteNome = new AutoCompleteTextField();
TextField autoCompleteCargo = new AutoCompleteTextField();
Button btnRemove = new Button("Excluir");
hBox.setAlignment(Pos.CENTER);
hBox.setFillHeight(true);
hBox.setMinHeight(39);
hBox.setSpacing(5);
autoCompleteName.setAlignment(Pos.CENTER_LEFT);
autoCompleteName.autosize();
autoCompleteName.setMinHeight(30);
autoCompleteName.setPrefHeight(30);
autoCompleteName.setItems(data);
autoCompleteName.setPromptText("Nome");
hBox.getChildren().add(autoCompleteName);