This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gui] [PATCH] FYI: Fixes in java.awt.Component
- From: David Jee <djee at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: 13 Feb 2004 12:59:43 -0500
- Subject: [gui] [PATCH] FYI: Fixes in java.awt.Component
- Organization:
Hello,
I'm committing the following patch to java-gui-branch, which fixes a
couple bugs in java.awt.Component:
1. show() should only do something if the component is invisible at
the moment. Similarly, hide() should only do something if the
component is visible at the moment.
2. In setBound(), we should repaint lightweight component and its
parent container to reflect the change. This isn't necessary for
heavyweights, who will take care of themselves.
-David Jee
2004-02-13 David Jee <djee@redhat.com>
* java/awt/Component.java
(show): Only do something if component is invisible at the moment.
(hide): Only do something if component is visible at the moment.
(reshape): If lightweight, erase old bounds and repaint new bounds.
Index: java/awt/Component.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Component.java,v
retrieving revision 1.37
diff -u -r1.37 Component.java
--- java/awt/Component.java 10 Feb 2004 18:57:22 -0000 1.37
+++ java/awt/Component.java 13 Feb 2004 17:03:19 -0000
@@ -876,10 +876,13 @@
// 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();
+ }
}
/**
@@ -903,10 +906,13 @@
*/
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();
+ }
}
/**
@@ -1315,6 +1321,11 @@
*/
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 +1336,15 @@
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();
+ }
}
/**