< prev index next >

src/windows/classes/sun/awt/windows/WCanvasPeer.java

Print this page
rev 1556 : 6794764: Translucent windows are completely repainted on every paint event, on Windows
6719382: Printing of AWT components on windows is not working
6726866: Repainting artifacts when resizing or dragging JInternalFrames in non-opaque toplevel
6683775: Painting artifacts is seen when panel is made setOpaque(false) for a translucent window
Reviewed-by: anthony, tdv, alexp


  93         if (bg != null) {
  94             setBackground(bg);
  95         }
  96     }
  97 
  98     public void paint(Graphics g) {
  99         Dimension d = ((Component)target).getSize();
 100         if (g instanceof Graphics2D ||
 101             g instanceof sun.awt.Graphics2Delegate) {
 102             // background color is setup correctly, so just use clearRect
 103             g.clearRect(0, 0, d.width, d.height);
 104         } else {
 105             // emulate clearRect
 106             g.setColor(((Component)target).getBackground());
 107             g.fillRect(0, 0, d.width, d.height);
 108             g.setColor(((Component)target).getForeground());
 109         }
 110         super.paint(g);
 111     }
 112 
 113     public void print(Graphics g) {
 114         if (!(target instanceof Window) ||
 115             AWTAccessor.getWindowAccessor().isOpaque((Window)target))
 116         {
 117             Dimension d = ((Component)target).getSize();
 118             if (g instanceof Graphics2D ||
 119                 g instanceof sun.awt.Graphics2Delegate) {
 120                 // background color is setup correctly, so just use clearRect
 121                 g.clearRect(0, 0, d.width, d.height);
 122             } else {
 123                 // emulate clearRect
 124                 g.setColor(((Component)target).getBackground());
 125                 g.fillRect(0, 0, d.width, d.height);
 126                 g.setColor(((Component)target).getForeground());
 127             }
 128         }
 129         super.print(g);
 130     }
 131 
 132     public boolean shouldClearRectBeforePaint() {
 133         return eraseBackground;
 134     }
 135 
 136     /*
 137      * Disables background erasing for this canvas, both for resizing
 138      * and not-resizing repaints.
 139      */
 140     void disableBackgroundErase() {
 141         eraseBackground = false;
 142         setNativeBackgroundErase(false, false);
 143     }
 144 
 145     /*
 146      * Sets background erasing flags at the native level. If {@code
 147      * doErase} is set to {@code true}, canvas background is erased on
 148      * every repaint. If {@code doErase} is {@code false} and {@code
 149      * doEraseOnResize} is {@code true}, then background is only erased
 150      * on resizing repaints. If both {@code doErase} and {@code
 151      * doEraseOnResize} are false, then background is never erased.


  93         if (bg != null) {
  94             setBackground(bg);
  95         }
  96     }
  97 
  98     public void paint(Graphics g) {
  99         Dimension d = ((Component)target).getSize();
 100         if (g instanceof Graphics2D ||
 101             g instanceof sun.awt.Graphics2Delegate) {
 102             // background color is setup correctly, so just use clearRect
 103             g.clearRect(0, 0, d.width, d.height);
 104         } else {
 105             // emulate clearRect
 106             g.setColor(((Component)target).getBackground());
 107             g.fillRect(0, 0, d.width, d.height);
 108             g.setColor(((Component)target).getForeground());
 109         }
 110         super.paint(g);
 111     }
 112 



















 113     public boolean shouldClearRectBeforePaint() {
 114         return eraseBackground;
 115     }
 116 
 117     /*
 118      * Disables background erasing for this canvas, both for resizing
 119      * and not-resizing repaints.
 120      */
 121     void disableBackgroundErase() {
 122         eraseBackground = false;
 123         setNativeBackgroundErase(false, false);
 124     }
 125 
 126     /*
 127      * Sets background erasing flags at the native level. If {@code
 128      * doErase} is set to {@code true}, canvas background is erased on
 129      * every repaint. If {@code doErase} is {@code false} and {@code
 130      * doEraseOnResize} is {@code true}, then background is only erased
 131      * on resizing repaints. If both {@code doErase} and {@code
 132      * doEraseOnResize} are false, then background is never erased.
< prev index next >