Created
August 25, 2022 03:00
-
-
Save Vzor-/e23c5faa79218d12644d7fe664e3831e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.WindowAdapter; | |
import java.awt.event.WindowEvent; | |
import java.lang.reflect.InvocationTargetException; | |
public class DialogTest { | |
public static void main(String[] args) throws InterruptedException, InvocationTargetException { | |
final JDialog dialog = new JDialog((Frame)null, | |
"Close me", | |
true); | |
dialog.setSize(200, 100); | |
dialog.addWindowListener(new WindowAdapter() { | |
public void windowClosing(WindowEvent we) { | |
JOptionPane.showMessageDialog(null, "Are you sure?"); | |
// Uncomment to fix issue | |
// try { | |
// Thread.sleep(500); | |
// } catch (InterruptedException ex) { | |
// throw new RuntimeException(ex); | |
// } | |
} | |
}); | |
SwingUtilities.invokeAndWait(() -> dialog.setVisible(true)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment