jdk/src/share/classes/java/awt/TextComponent.java

Print this page
rev 5725 : Merge

@@ -105,16 +105,10 @@
     // A flag used to tell whether the background has been set by
     // developer code (as opposed to AWT code).  Used to determine
     // the background color of non-editable TextComponents.
     boolean backgroundSetByClientCode = false;
 
-    /**
-     * True if this <code>TextComponent</code> has access
-     * to the System clipboard.
-     */
-    transient private boolean canAccessClipboard;
-
     transient protected TextListener textListener;
 
     /*
      * JDK 1.1 serialVersionUID
      */

@@ -135,11 +129,10 @@
      */
     TextComponent(String text) throws HeadlessException {
         GraphicsEnvironment.checkHeadless();
         this.text = (text != null) ? text : "";
         setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
-        checkSystemClipboardAccess();
     }
 
     private void enableInputMethodsIfNecessary() {
         if (checkForEnableIM) {
             checkForEnableIM = false;

@@ -730,21 +723,18 @@
     }
 
     /**
      * Assigns a valid value to the canAccessClipboard instance variable.
      */
-    private void checkSystemClipboardAccess() {
-        canAccessClipboard = true;
+    private boolean canAccessClipboard() {
         SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
+        if (sm == null) return true;
             try {
                 sm.checkSystemClipboardAccess();
-            }
-            catch (SecurityException e) {
-                canAccessClipboard = false;
-            }
-        }
+            return true;
+        } catch (SecurityException e) {}
+        return false;
     }
 
     /*
      * Serialization support.
      */

@@ -823,11 +813,10 @@
                 // skip value for unrecognized key
                 s.readObject();
             }
         }
         enableInputMethodsIfNecessary();
-        checkSystemClipboardAccess();
     }
 
 
 /////////////////
 // Accessibility support