private void buildForm() { addTitledGroupBg(root, gridRow, 1, "Manage accounts"); Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, "Your cryptocurrency accounts:", Layout.FIRST_ROW_DISTANCE); GridPane.setValignment(tuple.first, VPos.TOP); paymentAccountsListView = tuple.second; paymentAccountsListView.setPrefHeight(2 * Layout.LIST_ROW_HEIGHT + 14); paymentAccountsListView.setCellFactory( new Callback<ListView<PaymentAccount>, ListCell<PaymentAccount>>() { @Override public ListCell<PaymentAccount> call(ListView<PaymentAccount> list) { return new ListCell<PaymentAccount>() { final Label label = new Label(); final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON); final Button removeButton = new Button("", icon); final AnchorPane pane = new AnchorPane(label, removeButton); { label.setLayoutY(5); removeButton.setId("icon-button"); AnchorPane.setRightAnchor(removeButton, 0d); } @Override public void updateItem(final PaymentAccount item, boolean empty) { super.updateItem(item, empty); if (item != null && !empty) { label.setText(item.getAccountName()); removeButton.setOnAction(e -> onDeleteAccount(item)); setGraphic(pane); } else { setGraphic(null); } } }; } }); addAccountButton = addButtonAfterGroup(root, ++gridRow, "Add new account"); addAccountButton.setOnAction(event -> addNewAccount()); }