diff options
Diffstat (limited to 'java/awt/Container.java')
-rw-r--r-- | java/awt/Container.java | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/java/awt/Container.java b/java/awt/Container.java index 35c281a65..6d4a34571 100644 --- a/java/awt/Container.java +++ b/java/awt/Container.java @@ -451,9 +451,6 @@ public class Container extends Component ContainerEvent.COMPONENT_REMOVED, r); getToolkit().getSystemEventQueue().postEvent(ce); - - // Repaint this container. - repaint(); } } } @@ -1638,30 +1635,19 @@ public class Container extends Component Component comp) { Rectangle bounds = comp.getBounds(); - Rectangle oldClip = gfx.getClipBounds(); - if (oldClip == null) - oldClip = bounds; - - Rectangle clip = oldClip.intersection(bounds); - if (clip.isEmpty()) return; + if(!gfx.hitClip(bounds.x,bounds.y, bounds.width, bounds.height)) + return; - boolean clipped = false; - boolean translated = false; + Graphics g2 = gfx.create(bounds.x, bounds.y, bounds.width, + bounds.height); try { - gfx.setClip(clip.x, clip.y, clip.width, clip.height); - clipped = true; - gfx.translate(bounds.x, bounds.y); - translated = true; - visitor.visit(comp, gfx); + visitor.visit(comp, g2); } finally { - if (translated) - gfx.translate (-bounds.x, -bounds.y); - if (clipped) - gfx.setClip (oldClip.x, oldClip.y, oldClip.width, oldClip.height); + g2.dispose(); } } @@ -2161,12 +2147,18 @@ class LightweightDispatcher implements Serializable break; } - if (me.getID() == MouseEvent.MOUSE_PRESSED && modifiers > 0 + if (me.getID() == MouseEvent.MOUSE_RELEASED + || me.getID() == MouseEvent.MOUSE_PRESSED && modifiers > 0 || me.getID() == MouseEvent.MOUSE_DRAGGED) { // If any of the following events occur while a button is held down, // they should be dispatched to the same component to which the // original MOUSE_PRESSED event was dispatched: + // - MOUSE_RELEASED: This is important for correct dragging + // behaviour, otherwise the release goes to an arbitrary component + // outside of the dragged component. OTOH, if there is no mouse + // drag while the mouse is pressed, the component under the mouse + // is the same as the previously pressed component anyway. // - MOUSE_PRESSED: another button pressed while the first is held // down // - MOUSE_DRAGGED |