List of usage examples for javafx.scene.control TextField getPrefWidth
public final double getPrefWidth()
From source file:account.management.controller.NewVoucherController.java
@FXML private void onAddNewFieldButtonClick(ActionEvent event) { HBox row = new HBox(); row.setId("field_row"); ComboBox<Account> select_account = new ComboBox<>(); if (this.select_type.getSelectionModel().isEmpty()) { select_account.getItems().addAll(this.account_list); } else {/*from w ww . j a v a2 s . co m*/ select_account.getItems().addAll(this.filter_acc); } TextField dr = new TextField(); TextField cr = new TextField(); TextField remarks = new TextField(); Button del_row = new Button("Delete"); row.setSpacing(field_row.getSpacing()); ComboBox<Account> combo = (ComboBox) field_row.getChildren().get(0); select_account.setPrefWidth(combo.getPrefWidth()); select_account.setPromptText("Select account"); TextField tf = (TextField) field_row.getChildren().get(1); dr.setPrefWidth(tf.getPrefWidth()); dr.setPromptText("Dr"); tf = (TextField) field_row.getChildren().get(2); cr.setPrefWidth(tf.getPrefWidth()); cr.setPromptText("Cr"); tf = (TextField) field_row.getChildren().get(3); remarks.setPrefWidth(tf.getPrefWidth()); remarks.setPromptText("remarks"); row.getChildren().addAll(select_account, dr, cr, remarks, del_row); field_container.getChildren().add(row); del_row.setOnMouseClicked((MouseEvent event1) -> { field_container.getChildren().removeAll(row); validateFields(); }); combo.setOnAction((e) -> { if (!combo.getSelectionModel().isEmpty() && combo.getSelectionModel().getSelectedItem().getId() == 21) { combo.setPromptText("Select Party"); combo.getItems().clear(); combo.getItems().addAll(this.filter_party_rec); } if (!combo.getSelectionModel().isEmpty() && combo.getSelectionModel().getSelectedItem().getId() == 34) { combo.getItems().clear(); combo.getItems().addAll(this.filter_party_pay); combo.setPromptText("Select Party"); } }); new AutoCompleteComboBoxListener<>(select_account); select_account.setOnHiding((e) -> { Account a = select_account.getSelectionModel().getSelectedItem(); select_account.setEditable(false); select_account.getSelectionModel().select(a); }); select_account.setOnShowing((e) -> { select_account.setEditable(true); }); validateFields(); }