7173873: JFrame.setDefaultCloseOperation(EXIT_ON_CLOSE) will never lead to SE if EXIT_ON_CLOSE is already set
authoralexsch
Fri, 15 Feb 2013 14:24:42 +0400
changeset 15976 f9578ba3a2c1
parent 15640 20892a2bbcbc
child 15977 225648de9c4d
7173873: JFrame.setDefaultCloseOperation(EXIT_ON_CLOSE) will never lead to SE if EXIT_ON_CLOSE is already set Reviewed-by: malenkov, serb
jdk/src/share/classes/javax/swing/JFrame.java
--- a/jdk/src/share/classes/javax/swing/JFrame.java	Wed Feb 13 12:38:28 2013 -0800
+++ b/jdk/src/share/classes/javax/swing/JFrame.java	Fri Feb 15 14:24:42 2013 +0400
@@ -387,13 +387,14 @@
             operation != EXIT_ON_CLOSE) {
             throw new IllegalArgumentException("defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, DISPOSE_ON_CLOSE, or EXIT_ON_CLOSE");
         }
+
+        if (operation == EXIT_ON_CLOSE) {
+            SecurityManager security = System.getSecurityManager();
+            if (security != null) {
+                security.checkExit(0);
+            }
+        }
         if (this.defaultCloseOperation != operation) {
-            if (operation == EXIT_ON_CLOSE) {
-                SecurityManager security = System.getSecurityManager();
-                if (security != null) {
-                    security.checkExit(0);
-                }
-            }
             int oldValue = this.defaultCloseOperation;
             this.defaultCloseOperation = operation;
             firePropertyChange("defaultCloseOperation", oldValue, operation);