changeset 634:34d4a2d5b8cb

6644301: lightweight components can repaint outside request bounds Summary: repaint() needs to adjust width and height if it receives negative x or y. Reviewed-by: art
author son
date Thu, 15 May 2008 11:34:11 +0400
parents 59439733e87a
children 7843f98417d1
files jdk/src/share/classes/java/awt/Component.java
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/share/classes/java/awt/Component.java	Sun May 04 07:05:42 2008 -0700
+++ b/jdk/src/share/classes/java/awt/Component.java	Thu May 15 11:34:11 2008 +0400
@@ -3052,10 +3052,24 @@
             // services.  Additionally, the request is restricted to
             // the bounds of the component.
             if (parent != null) {
-                int px = this.x + ((x < 0) ? 0 : x);
-                int py = this.y + ((y < 0) ? 0 : y);
+                if (x < 0) {
+                    width += x;
+                    x = 0;
+                }
+                if (y < 0) {
+                    height += y;
+                    y = 0;
+                }
+
                 int pwidth = (width > this.width) ? this.width : width;
                 int pheight = (height > this.height) ? this.height : height;
+
+                if (pwidth <= 0 || pheight <= 0) {
+                    return;
+                }
+
+                int px = this.x + x;
+                int py = this.y + y;
                 parent.repaint(tm, px, py, pwidth, pheight);
             }
         } else {