src/share/classes/sun/awt/datatransfer/SunClipboard.java

Print this page

        

@@ -148,11 +148,11 @@
     /**
      * @return the contents of this clipboard if it has been set from the same
      *         AppContext as it is currently retrieved or null otherwise
      * @since 1.5
      */
-    private synchronized Transferable getContextContents() {
+    protected synchronized Transferable getContextContents() {
         AppContext context = AppContext.getAppContext();
         return (context == contentsContext) ? contents : null;
     }
 
 

@@ -279,12 +279,15 @@
         final AppContext context = this.contentsContext;
         if (context == null) {
             return;
         }
 
-        final Runnable runnable = new Runnable() {
-                public void run() {
+        SunToolkit.postEvent(context, new PeerEvent(this, () -> lostOwnershipNow(disposedContext),
+                                                    PeerEvent.PRIORITY_EVENT));
+    }
+
+    protected void lostOwnershipNow(final AppContext disposedContext) {
                     final SunClipboard sunClipboard = SunClipboard.this;
                     ClipboardOwner owner = null;
                     Transferable contents = null;
 
                     synchronized (sunClipboard) {

@@ -309,15 +312,11 @@
                     }
                     if (owner != null) {
                         owner.lostOwnership(sunClipboard, contents);
                     }
                 }
-            };
 
-        SunToolkit.postEvent(context, new PeerEvent(this, runnable,
-                                                    PeerEvent.PRIORITY_EVENT));
-    }
 
     protected abstract void clearNativeContext();
 
     protected abstract void setContentsNative(Transferable contents);