void (ActionEvent e1) { setTitle("Dialog [0]"); Thread thread = new Thread(() -> { try { for (int i = 0; i < 300; i++) { final int ii = i; SwingUtilities.invokeLater(() -> setTitle("Dialog [" + ii + "]")); } } catch (Exception ignore) { } }, "Dialog [0]"); thread.start(); Messages.showYesNoDialog(b, MESSAGE, TITLE, Messages.getQuestionIcon()); if (thread.isAlive()) { thread.interrupt(); } }