--- old/src/share/classes/javax/swing/JComponent.java 2014-05-22 17:04:59.000000000 +0400 +++ new/src/share/classes/javax/swing/JComponent.java 2014-05-22 17:04:59.000000000 +0400 @@ -63,6 +63,7 @@ import static javax.swing.ClientPropertyKey.*; import javax.accessibility.*; +import sun.awt.SunToolkit; import sun.swing.SwingUtilities2; import sun.swing.UIClientPropertyKey; @@ -4802,7 +4803,8 @@ * @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); } @@ -4856,7 +4858,7 @@ // which was causing some people grief. return; } - if (SwingUtilities.isEventDispatchThread()) { + if (SunToolkit.isDispatchThreadForAppContext(this)) { invalidate(); RepaintManager.currentManager(this).addInvalidComponent(this); } @@ -4870,15 +4872,12 @@ } setFlag(REVALIDATE_RUNNABLE_SCHEDULED, true); } - Runnable callRevalidate = new Runnable() { - public void run() { - synchronized(JComponent.this) { - setFlag(REVALIDATE_RUNNABLE_SCHEDULED, false); - } - revalidate(); + SunToolkit.executeOnEventHandlerThread(this, () -> { + synchronized(JComponent.this) { + setFlag(REVALIDATE_RUNNABLE_SCHEDULED, false); } - }; - SwingUtilities.invokeLater(callRevalidate); + revalidate(); + }); } }