< prev index next >

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

Print this page

        

@@ -108,10 +108,12 @@
 
     boolean   doubleBufferingEnabled = true;
 
     private Dimension doubleBufferMaxSize;
 
+    private boolean isCustomMaxBufferSizeSet = false;
+
     // Support for both the standard and volatile offscreen buffers exists to
     // provide backwards compatibility for the [rare] programs which may be
     // calling getOffScreenBuffer() and not expecting to get a VolatileImage.
     // Swing internally is migrating to use *only* the volatile image buffer.
 

@@ -333,11 +335,17 @@
         }
         processingRunnable = new ProcessingRunnable();
     }
 
     private void displayChanged() {
+        if (isCustomMaxBufferSizeSet) {
         clearImages();
+        } else {
+            // Reset buffer maximum size to get valid size from updated graphics
+            // environment in getDoubleBufferMaximumSize()
+            setDoubleBufferMaximumSize(null);
+        }
     }
 
     /**
      * Mark the component as in need of layout and queue a runnable
      * for the event dispatching thread that will validate the components

@@ -1154,12 +1162,14 @@
      * @param d the dimension
      */
     public void setDoubleBufferMaximumSize(Dimension d) {
         doubleBufferMaxSize = d;
         if (doubleBufferMaxSize == null) {
+            isCustomMaxBufferSizeSet = false;
             clearImages();
         } else {
+            isCustomMaxBufferSizeSet = true;
             clearImages(d.width, d.height);
         }
     }
 
     private void clearImages() {
< prev index next >