Created
September 22, 2022 16:44
-
-
Save Vzor-/ad2d18bfda4bcdc6b6915851dcace76c 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