private NewFolderPane(Function<String, F> folderCreator, Predicate<String> folderUnique) { this.folderCreator = Objects.requireNonNull(folderCreator); setVgap(5); setHgap(5); ColumnConstraints column0 = new ColumnConstraints(); ColumnConstraints column1 = new ColumnConstraints(); column1.setHgrow(Priority.ALWAYS); getColumnConstraints().addAll(column0, column1); add(new Label(RESOURCE_BUNDLE.getString("Name")), 0, 0); add(nameTextField, 1, 0); add(fileAlreadyExistLabel, 0, 1, 2, 1); fileAlreadyExistLabel.setTextFill(Color.RED); nameTextField.textProperty().addListener((observable, oldName, newName) -> uniqueName.setValue(newName == null || folderUnique.test(newName))); uniqueName.addListener((observable, oldUnique, newUnique) -> { if (newUnique) { fileAlreadyExistLabel.setText(""); } else { fileAlreadyExistLabel.setText(MessageFormat.format(RESOURCE_BUNDLE.getString("FileAlreadyExistsInThisFolder"), nameTextField.getText())); } }); Platform.runLater(nameTextField::requestFocus); }