I wonder if this is the right way for getting a PIN from a dialog?
public static <T> T getFromGui(Supplier<T> supplier) {
if (CN.isEdt()) return supplier.get();
final Object[] holder = new Object[1];
CN.callSeriallyAndWait(() -> holder[0] = supplier.get());
@SuppressWarnings("unchecked") final T result = (T) holder[0];
return result;
}
public static String askPin() {
if (!CN.isEdt()) return getFromGui(() -> askPin(bankzugang));
...
final boolean cont = Dialog.show(
"Your PIN", BoxLayout.encloseY(pin, label), ok, cancel) == ok;
return cont? pin.getText() : "";
}
It seems to work (tried once), but I'm a bit confused about callSeriallyAndWait: Is it the analogon of SwingUtilities.invokeAndWait? What are the differences?
Actually, I need a few dialogs to work from every thread, including EDT. Is there a better way than adding the "getFromGui" line to each of them as above?