src/share/classes/javax/swing/JComponent.java

Print this page

        

@@ -61,10 +61,11 @@
 import javax.swing.event.*;
 import javax.swing.plaf.*;
 import static javax.swing.ClientPropertyKey.*;
 import javax.accessibility.*;
 
+import sun.awt.SunToolkit;
 import sun.swing.SwingUtilities2;
 import sun.swing.UIClientPropertyKey;
 
 /**
  * The base class for all Swing components except top-level containers.

@@ -4800,11 +4801,12 @@
      * @see #isPaintingOrigin()
      * @see java.awt.Component#isShowing
      * @see RepaintManager#addDirtyRegion
      */
     public void repaint(long tm, int x, int y, int width, int height) {
-        RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width, height);
+        RepaintManager.currentManager(SunToolkit.targetToAppContext(this))
+                      .addDirtyRegion(this, x, y, width, height);
     }
 
 
     /**
      * Adds the specified region to the dirty region list if the component

@@ -4854,11 +4856,11 @@
             // new Component). Also, if we do add a check to isValid
             // here it can potentially be called before the constructor
             // which was causing some people grief.
             return;
         }
-        if (SwingUtilities.isEventDispatchThread()) {
+        if (SunToolkit.isDispatchThreadForAppContext(this)) {
             invalidate();
             RepaintManager.currentManager(this).addInvalidComponent(this);
         }
         else {
             // To avoid a flood of Runnables when constructing GUIs off

@@ -4868,19 +4870,16 @@
                 if (getFlag(REVALIDATE_RUNNABLE_SCHEDULED)) {
                     return;
                 }
                 setFlag(REVALIDATE_RUNNABLE_SCHEDULED, true);
             }
-            Runnable callRevalidate = new Runnable() {
-                public void run() {
+            SunToolkit.executeOnEventHandlerThread(this, () -> {
                     synchronized(JComponent.this) {
                         setFlag(REVALIDATE_RUNNABLE_SCHEDULED, false);
                     }
                     revalidate();
-                }
-            };
-            SwingUtilities.invokeLater(callRevalidate);
+            });
         }
     }
 
     /**
      * If this method returns true, <code>revalidate</code> calls by