From 35ab35d2097ca1e4f80e1c26e6076d3f00bb96be Mon Sep 17 00:00:00 2001 From: rusefi Date: Mon, 17 Jan 2022 16:46:36 -0500 Subject: [PATCH] UI thread is the thread to open dialogs --- .../main/java/com/rusefi/io/serial/PortHolder.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/java_console/io/src/main/java/com/rusefi/io/serial/PortHolder.java b/java_console/io/src/main/java/com/rusefi/io/serial/PortHolder.java index ca40f97038..b61ec7472b 100644 --- a/java_console/io/src/main/java/com/rusefi/io/serial/PortHolder.java +++ b/java_console/io/src/main/java/com/rusefi/io/serial/PortHolder.java @@ -84,11 +84,13 @@ public class PortHolder { */ public void packAndSend(final String command, boolean fireEvent) throws InterruptedException { if (bp == null) { - Window[] windows = JDialog.getWindows(); - Window window = windows.length == 0 ? null : windows[0]; - JOptionPane.showMessageDialog(window, "No connectivity", - "Error", JOptionPane.ERROR_MESSAGE); - System.exit(-1); + SwingUtilities.invokeLater(() -> { + Window[] windows = JDialog.getWindows(); + Window window = windows.length == 0 ? null : windows[0]; + JOptionPane.showMessageDialog(window, "No connectivity, will close", + "Error", JOptionPane.ERROR_MESSAGE); + System.exit(-1); + }); } bp.doSend(command, fireEvent);