diff options
Diffstat (limited to 'libjava/java/awt/Component.java')
-rw-r--r-- | libjava/java/awt/Component.java | 99 |
1 files changed, 90 insertions, 9 deletions
diff --git a/libjava/java/awt/Component.java b/libjava/java/awt/Component.java index 3d2afc9..8c75ba0 100644 --- a/libjava/java/awt/Component.java +++ b/libjava/java/awt/Component.java @@ -876,10 +876,16 @@ public abstract class Component // case lightweight components are not initially painted -- // Container.paint first calls isShowing () before painting itself // and its children. - this.visible = true; - if (peer != null) - peer.setVisible(true); - invalidate(); + if(!isVisible()) + { + this.visible = true; + if (peer != null) + peer.setVisible(true); + invalidate(); + ComponentEvent ce = + new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN); + getToolkit().getSystemEventQueue().postEvent(ce); + } } /** @@ -903,10 +909,16 @@ public abstract class Component */ public void hide() { - if (peer != null) - peer.setVisible(false); - this.visible = false; - invalidate(); + if (isVisible()) + { + if (peer != null) + peer.setVisible(false); + this.visible = false; + invalidate(); + ComponentEvent ce = + new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN); + getToolkit().getSystemEventQueue().postEvent(ce); + } } /** @@ -974,8 +986,11 @@ public abstract class Component */ public void setBackground(Color c) { + // If c is null, inherit from closest ancestor whose bg is set. + if (c == null && parent != null) + c = parent.getBackground(); firePropertyChange("background", background, c); - if (peer != null) + if (peer != null && c != null) peer.setBackground(c); background = c; } @@ -1022,6 +1037,7 @@ public abstract class Component firePropertyChange("font", font, f); if (peer != null) peer.setFont(f); + invalidate(); font = f; } @@ -1150,6 +1166,9 @@ public abstract class Component */ public void move(int x, int y) { + int oldx = this.x; + int oldy = this.y; + if (this.x == x && this.y == y) return; invalidate (); @@ -1157,6 +1176,20 @@ public abstract class Component this.y = y; if (peer != null) peer.setBounds (x, y, width, height); + + // Erase old bounds and repaint new bounds for lightweights. + if (isLightweight() && width != 0 && height !=0) + { + parent.repaint(oldx, oldy, width, height); + repaint(); + } + + if (oldx != x || oldy != y) + { + ComponentEvent ce = new ComponentEvent(this, + ComponentEvent.COMPONENT_MOVED); + getToolkit().getSystemEventQueue().postEvent(ce); + } } /** @@ -1220,6 +1253,9 @@ public abstract class Component */ public void resize(int width, int height) { + int oldwidth = this.width; + int oldheight = this.height; + if (this.width == width && this.height == height) return; invalidate (); @@ -1227,6 +1263,22 @@ public abstract class Component this.height = height; if (peer != null) peer.setBounds (x, y, width, height); + + // Erase old bounds and repaint new bounds for lightweights. + if (isLightweight()) + { + if (oldwidth != 0 && oldheight != 0 && parent != null) + parent.repaint(x, y, oldwidth, oldheight); + if (width != 0 && height != 0) + repaint(); + } + + if (oldwidth != width || oldheight != height) + { + ComponentEvent ce = + new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED); + getToolkit().getSystemEventQueue().postEvent(ce); + } } /** @@ -1315,6 +1367,11 @@ public abstract class Component */ public void reshape(int x, int y, int width, int height) { + int oldx = this.x; + int oldy = this.y; + int oldwidth = this.width; + int oldheight = this.height; + if (this.x == x && this.y == y && this.width == width && this.height == height) return; @@ -1325,6 +1382,28 @@ public abstract class Component this.height = height; if (peer != null) peer.setBounds (x, y, width, height); + + // Erase old bounds and repaint new bounds for lightweights. + if (isLightweight()) + { + if (oldwidth != 0 && oldheight != 0 && parent != null) + parent.repaint(oldx, oldy, oldwidth, oldheight); + if (width != 0 && height != 0) + repaint(); + } + + if (oldx != x || oldy != y) + { + ComponentEvent ce = new ComponentEvent(this, + ComponentEvent.COMPONENT_MOVED); + getToolkit().getSystemEventQueue().postEvent(ce); + } + if (oldwidth != width || oldheight != height) + { + ComponentEvent ce = new ComponentEvent(this, + ComponentEvent.COMPONENT_RESIZED); + getToolkit().getSystemEventQueue().postEvent(ce); + } } /** @@ -4172,6 +4251,8 @@ p * <li>the set of backward traversal keys case MouseEvent.MOUSE_EXITED: case MouseEvent.MOUSE_PRESSED: case MouseEvent.MOUSE_RELEASED: + case MouseEvent.MOUSE_MOVED: + case MouseEvent.MOUSE_DRAGGED: return (mouseListener != null || mouseMotionListener != null || (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0); |