src/java.desktop/share/classes/javax/swing/RepaintManager.java

Print this page

        

@@ -180,13 +180,20 @@
     /**
      * Runnable used to process all repaint/revalidate requests.
      */
     private final ProcessingRunnable processingRunnable;
 
-    private final static JavaSecurityAccess javaSecurityAccess =
+    private static final JavaSecurityAccess javaSecurityAccess =
         SharedSecrets.getJavaSecurityAccess();
 
+    /**
+     * Listener installed to detect display changes. When display changes,
+     * schedules a callback to notify all RepaintManagers of the display
+     * changes.
+     */
+    private static final DisplayChangedListener displayChangedHandler =
+            new DisplayChangedHandler();
 
     static {
         SwingAccessor.setRepaintManagerAccessor(new SwingAccessor.RepaintManagerAccessor() {
             @Override
             public void addRepaintListener(RepaintManager rm, RepaintListener l) {

@@ -224,12 +231,12 @@
         HANDLE_TOP_LEVEL_PAINT = "true".equals(AccessController.doPrivileged(
                new GetPropertyAction("swing.handleTopLevelPaint", "true")));
         GraphicsEnvironment ge = GraphicsEnvironment.
                 getLocalGraphicsEnvironment();
         if (ge instanceof SunGraphicsEnvironment) {
-            ((SunGraphicsEnvironment)ge).addDisplayChangedListener(
-                    new DisplayChangedHandler());
+            ((SunGraphicsEnvironment) ge).addDisplayChangedListener(
+                    displayChangedHandler);
         }
         Toolkit tk = Toolkit.getDefaultToolkit();
         if ((tk instanceof SunToolkit)
                 && ((SunToolkit) tk).isSwingBackbufferTranslucencySupported()) {
             volatileBufferType = Transparency.TRANSLUCENT;

@@ -1677,22 +1684,27 @@
      * changes. Only one DisplayChangedHandler is ever installed. The
      * singleton instance will schedule notification for all AppContexts.
      */
     private static final class DisplayChangedHandler implements
                                              DisplayChangedListener {
+        // Empty non private constructor was added because access to this
+        // class shouldn't be emulated by a synthetic accessor method.
+        DisplayChangedHandler() {
+            super();
+        }
+
         public void displayChanged() {
             scheduleDisplayChanges();
         }
 
         public void paletteChanged() {
         }
 
-        private void scheduleDisplayChanges() {
+        private static void scheduleDisplayChanges() {
             // To avoid threading problems, we notify each RepaintManager
             // on the thread it was created on.
-            for (Object c : AppContext.getAppContexts()) {
-                AppContext context = (AppContext) c;
+            for (AppContext context : AppContext.getAppContexts()) {
                 synchronized(context) {
                     if (!context.isDisposed()) {
                         EventQueue eventQueue = (EventQueue)context.get(
                             AppContext.EVENT_QUEUE_KEY);
                         if (eventQueue != null) {