diff options
Diffstat (limited to 'libjava/java/awt/Component.java')
-rw-r--r-- | libjava/java/awt/Component.java | 118 |
1 files changed, 62 insertions, 56 deletions
diff --git a/libjava/java/awt/Component.java b/libjava/java/awt/Component.java index 87c73b5..f2fcef5 100644 --- a/libjava/java/awt/Component.java +++ b/libjava/java/awt/Component.java @@ -779,9 +779,7 @@ public abstract class Component */ public void setEnabled(boolean b) { - this.enabled = b; - if (peer != null) - peer.setEnabled(b); + enable (b); } /** @@ -791,7 +789,9 @@ public abstract class Component */ public void enable() { - setEnabled(true); + this.enabled = true; + if (peer != null) + peer.setEnabled (true); } /** @@ -802,7 +802,10 @@ public abstract class Component */ public void enable(boolean b) { - setEnabled(b); + if (b) + enable (); + else + disable (); } /** @@ -812,7 +815,9 @@ public abstract class Component */ public void disable() { - setEnabled(false); + this.enabled = false; + if (peer != null) + peer.setEnabled (false); } /** @@ -856,10 +861,7 @@ public abstract class Component // Inspection by subclassing shows that Sun's implementation calls // show(boolean) which then calls show() or hide(). It is the show() // method that is overriden in subclasses like Window. - if (b) - show(); - else - hide(); + show (b); } /** @@ -887,7 +889,10 @@ public abstract class Component */ public void show(boolean b) { - setVisible(b); + if (b) + show (); + else + hide (); } /** @@ -1083,7 +1088,7 @@ public abstract class Component */ public Point getLocation() { - return new Point(x, y); + return location (); } /** @@ -1110,7 +1115,7 @@ public abstract class Component */ public Point location() { - return getLocation(); + return new Point (x, y); } /** @@ -1125,13 +1130,7 @@ public abstract class Component */ public void setLocation(int x, int y) { - if (this.x == x && this.y == y) - return; - invalidate(); - this.x = x; - this.y = y; - if (peer != null) - peer.setBounds(x, y, width, height); + move (x, y); } /** @@ -1145,7 +1144,13 @@ public abstract class Component */ public void move(int x, int y) { - setLocation(x, y); + if (this.x == x && this.y == y) + return; + invalidate (); + this.x = x; + this.y = y; + if (peer != null) + peer.setBounds (x, y, width, height); } /** @@ -1173,7 +1178,7 @@ public abstract class Component */ public Dimension getSize() { - return new Dimension(width, height); + return size (); } /** @@ -1184,7 +1189,7 @@ public abstract class Component */ public Dimension size() { - return getSize(); + return new Dimension (width, height); } /** @@ -1197,13 +1202,7 @@ public abstract class Component */ public void setSize(int width, int height) { - if (this.width == width && this.height == height) - return; - invalidate(); - this.width = width; - this.height = height; - if (peer != null) - peer.setBounds(x, y, width, height); + resize (width, height); } /** @@ -1215,7 +1214,13 @@ public abstract class Component */ public void resize(int width, int height) { - setSize(width, height); + if (this.width == width && this.height == height) + return; + invalidate (); + this.width = width; + this.height = height; + if (peer != null) + peer.setBounds (x, y, width, height); } /** @@ -1229,7 +1234,7 @@ public abstract class Component */ public void setSize(Dimension d) { - setSize(d.width, d.height); + resize (d); } /** @@ -1241,7 +1246,7 @@ public abstract class Component */ public void resize(Dimension d) { - setSize(d.width, d.height); + resize (d.width, d.height); } /** @@ -1256,7 +1261,7 @@ public abstract class Component */ public Rectangle getBounds() { - return new Rectangle(x, y, width, height); + return bounds (); } /** @@ -1269,7 +1274,7 @@ public abstract class Component */ public Rectangle bounds() { - return getBounds(); + return new Rectangle (x, y, width, height); } /** @@ -1289,15 +1294,7 @@ public abstract class Component */ public void setBounds(int x, int y, int w, int h) { - if (this.x == x && this.y == y && width == w && height == h) - return; - invalidate(); - this.x = x; - this.y = y; - width = w; - height = h; - if (peer != null) - peer.setBounds(x, y, w, h); + reshape (x, y, w, h); } /** @@ -1306,13 +1303,22 @@ public abstract class Component * * @param x the X coordinate of the upper left corner of the rectangle * @param y the Y coordinate of the upper left corner of the rectangle - * @param w the width of the rectangle - * @param h the height of the rectangle + * @param width the width of the rectangle + * @param height the height of the rectangle * @deprecated use {@link #setBounds(int, int, int, int)} instead */ public void reshape(int x, int y, int width, int height) { - setBounds(x, y, width, height); + if (this.x == x && this.y == y + && this.width == width && this.height == height) + return; + invalidate (); + this.x = x; + this.y = y; + this.width = width; + this.height = height; + if (peer != null) + peer.setBounds (x, y, width, height); } /** @@ -1329,7 +1335,7 @@ public abstract class Component */ public void setBounds(Rectangle r) { - setBounds(r.x, r.y, r.width, r.height); + setBounds (r.x, r.y, r.width, r.height); } /** @@ -1560,7 +1566,7 @@ public abstract class Component */ public void doLayout() { - // nothing to do unless we're a container + layout (); } /** @@ -1571,7 +1577,7 @@ public abstract class Component */ public void layout() { - doLayout(); + // Nothing to do unless we're a container. } /** @@ -2076,7 +2082,7 @@ public abstract class Component */ public boolean contains(int x, int y) { - return x >= 0 && y >= 0 && x < width && y < height; + return inside (x, y); } /** @@ -2090,7 +2096,7 @@ public abstract class Component */ public boolean inside(int x, int y) { - return contains(x, y); + return x >= 0 && y >= 0 && x < width && y < height; } /** @@ -2105,7 +2111,7 @@ public abstract class Component */ public boolean contains(Point p) { - return contains(p.x, p.y); + return contains (p.x, p.y); } /** @@ -2120,7 +2126,7 @@ public abstract class Component */ public Component getComponentAt(int x, int y) { - return contains(x, y) ? this : null; + return locate (x, y); } /** @@ -2135,7 +2141,7 @@ public abstract class Component */ public Component locate(int x, int y) { - return getComponentAt(x, y); + return contains (x, y) ? this : null; } /** @@ -2151,7 +2157,7 @@ public abstract class Component */ public Component getComponentAt(Point p) { - return getComponentAt(p.x, p.y); + return getComponentAt (p.x, p.y); } /** |