8073420: JFrame.EXIT_ON_CLOSE can be removed in favour of WindowConstants.EXIT_ON_CLOSE
authorserb
Tue, 03 Mar 2015 20:23:34 +0300
changeset 29511 7c491ff8a5fc
parent 29510 9c567246bdae
child 29512 073c09fc07fd
8073420: JFrame.EXIT_ON_CLOSE can be removed in favour of WindowConstants.EXIT_ON_CLOSE Reviewed-by: art, azvegint, alexsch
jdk/src/demo/share/java2d/J2DBench/src/j2dbench/J2DBench.java
jdk/src/demo/share/jfc/SampleTree/SampleTree.java
jdk/src/demo/share/management/JTop/JTop.java
jdk/src/java.desktop/share/classes/javax/swing/JFrame.java
jdk/src/java.desktop/share/classes/javax/swing/JLayer.java
--- a/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/J2DBench.java	Tue Mar 03 17:50:01 2015 +0300
+++ b/jdk/src/demo/share/java2d/J2DBench/src/j2dbench/J2DBench.java	Tue Mar 03 20:23:34 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -61,6 +61,7 @@
 import javax.swing.JFileChooser;
 import javax.swing.JOptionPane;
 import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -698,7 +699,7 @@
             }
         };
         guiFrame = f;
-        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
         f.getContentPane().setLayout(new BorderLayout());
         f.getContentPane().add(Group.root.getJComponent(), BorderLayout.CENTER);
         JPanel p = new JPanel();
--- a/jdk/src/demo/share/jfc/SampleTree/SampleTree.java	Tue Mar 03 17:50:01 2015 +0300
+++ b/jdk/src/demo/share/jfc/SampleTree/SampleTree.java	Tue Mar 03 20:23:34 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -135,7 +135,7 @@
         panel.add("Center", sp);
         panel.add("South", constructOptionsPanel());
 
-        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
         frame.pack();
         frame.setVisible(true);
     }
--- a/jdk/src/demo/share/management/JTop/JTop.java	Tue Mar 03 17:50:01 2015 +0300
+++ b/jdk/src/demo/share/management/JTop/JTop.java	Tue Mar 03 20:23:34 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -410,7 +410,7 @@
     private static void createAndShowGUI(JPanel jtop) {
         // Create and set up the window.
         JFrame frame = new JFrame("JTop");
-        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 
         // Create and set up the content pane.
         JComponent contentPane = (JComponent) frame.getContentPane();
--- a/jdk/src/java.desktop/share/classes/javax/swing/JFrame.java	Tue Mar 03 17:50:01 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JFrame.java	Tue Mar 03 20:23:34 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -128,16 +128,6 @@
                               TransferHandler.HasGetTransferHandler
 {
     /**
-     * The exit application default window close operation. If a window
-     * has this set as the close operation and is closed in an applet,
-     * a <code>SecurityException</code> may be thrown.
-     * It is recommended you only use this in an application.
-     *
-     * @since 1.3
-     */
-    public static final int EXIT_ON_CLOSE = 3;
-
-    /**
      * Key into the AppContext, used to check if should provide decorations
      * by default.
      */
@@ -352,7 +342,7 @@
      * objects.
      *
      * <li><code>EXIT_ON_CLOSE</code>
-     * (defined in <code>JFrame</code>):
+     * (defined in <code>WindowConstants</code>):
      * Exit the application using the <code>System</code>
      * <code>exit</code> method.  Use this only in applications.
      * </ul>
@@ -393,7 +383,9 @@
             operation != HIDE_ON_CLOSE &&
             operation != DISPOSE_ON_CLOSE &&
             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");
+            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) {
@@ -861,7 +853,7 @@
             defaultCloseOperationString = "DISPOSE_ON_CLOSE";
         } else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) {
             defaultCloseOperationString = "DO_NOTHING_ON_CLOSE";
-        } else if (defaultCloseOperation == 3) {
+        } else if (defaultCloseOperation == EXIT_ON_CLOSE) {
             defaultCloseOperationString = "EXIT_ON_CLOSE";
         } else defaultCloseOperationString = "";
         String rootPaneString = (rootPane != null ?
--- a/jdk/src/java.desktop/share/classes/javax/swing/JLayer.java	Tue Mar 03 17:50:01 2015 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JLayer.java	Tue Mar 03 20:23:34 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -103,7 +103,7 @@
  *
  *     private static void createAndShowGUI() {
  *         final JFrame frame = new JFrame();
- *         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ *         frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  *
  *         // work with the layer as with any other Swing component
  *         frame.add(createLayer());