Dialog<String> dialog = new Dialog<>();
TextArea textArea = new TextArea("text");
ButtonType zmianButton = new ButtonType("OK", ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(zmianButton, ButtonType.CANCEL);
dialog.setTitle("Lista");
dialog.getDialogPane().setContent(textArea);
Platform.runLater(() -> textArea.requestFocus());
dialog.setResultConverter(dialogButton -> {
if (dialogButton == zmianButton) {
return textArea.getText().trim();
}
return null;
});
Optional<String> result = dialog.showAndWait();
result.ifPresent((t) -> {
System.out.println("t:" + t);
});