我有一个包含很少文本字段的对话框。我希望对话框将这些结果作为String列表返回。 以下是如何返回字符串对的示例:
dialog.setResultConverter(dialogButton -> {
return new Pair<>(slotRequired.getText(), baseOffset.getText());
});
你知道如何使用String列表吗?
答案 0 :(得分:1)
将对话框设为Dialog<List<String>>
并执行
dialog.setResultConverter(dialogButton -> {
List<String> result = new ArrayList<>();
result.add(slotRequired.getText());
result.add(baseOffset.getText());
// add as many times as you need...
return result ;
});
或者,更简洁:
dialog.setResultConverter(dialogButton ->
Arrays.asList(slotRequired.getText(), baseOffset.getText() /*, as many as you need...*/));