From 69a10f680ae409a90d10beace5f7cc3d254b0d32 Mon Sep 17 00:00:00 2001 From: Oleg Sukhodolsky Date: Thu, 15 May 2008 11:34:11 +0400 Subject: [PATCH] 6644301: lightweight components can repaint outside request bounds Repaint() needs to adjust width and height if it receives negative x or y. Reviewed-by: art --- jdk/src/share/classes/java/awt/Component.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/java/awt/Component.java b/jdk/src/share/classes/java/awt/Component.java index 22fb95f5aa9..aa9f593127e 100644 --- a/jdk/src/share/classes/java/awt/Component.java +++ b/jdk/src/share/classes/java/awt/Component.java @@ -3052,10 +3052,24 @@ public abstract class Component implements ImageObserver, MenuContainer, // 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 {