summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLillian Angel <langel@redhat.com>2006-05-03 14:29:45 +0000
committerLillian Angel <langel@redhat.com>2006-05-03 14:29:45 +0000
commitb1435b6463221a407390335be2c2f59b812d0333 (patch)
treee243527118f6059179b64ab5c176f32a061ada81
parentfb8804a9c4b9fd3117e3ab58c1241b76b7d0f199 (diff)
downloadclasspath-b1435b6463221a407390335be2c2f59b812d0333.tar.gz
2006-05-03 Lillian Angel <langel@redhat.com>
* javax/swing/JComponent.java (getRoot): New private function. Gets the root appropriate for painting. If an applet exists as a parent, then it is returned. (paintDoubleBuffered): Changed to use new function. * javax/swing/RepaintManager.java (getRoot): New private function. Gets the root appropriate for painting. If an applet exists as a parent, then it is returned. (getOffscreenBuffer): Changed to use new function. * javax/swing/SwingUtilties.java (getRoot): Reverted last patch to return Window, even if an Applet exists.
-rw-r--r--ChangeLog14
-rw-r--r--javax/swing/JComponent.java29
-rw-r--r--javax/swing/RepaintManager.java32
-rw-r--r--javax/swing/SwingUtilities.java16
4 files changed, 79 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 6b387f92c..e3a2d76be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2006-05-03 Lillian Angel <langel@redhat.com>
+
+ * javax/swing/JComponent.java
+ (getRoot): New private function. Gets the root appropriate
+ for painting. If an applet exists as a parent, then it is returned.
+ (paintDoubleBuffered): Changed to use new function.
+ * javax/swing/RepaintManager.java
+ (getRoot): New private function. Gets the root appropriate
+ for painting. If an applet exists as a parent, then it is returned.
+ (getOffscreenBuffer): Changed to use new function.
+ * javax/swing/SwingUtilties.java
+ (getRoot): Reverted last patch to return Window, even if
+ an Applet exists.
+
2006-05-03 Raif S. Naffah <raif@swiftdsl.com.au>
* gnu/javax/crypto/jce/keyring/GnuKeyring.java: Re-implemented using
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index a84122ab7..f8d82c736 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -2159,6 +2159,33 @@ public abstract class JComponent extends Container implements Serializable
}
/**
+ * Gets the root of the component given. If a parent of the
+ * component is an instance of Applet, then the applet is
+ * returned. The applet is considered the root for painting
+ * and adding/removing components. Otherwise, the root Window
+ * is returned if it exists.
+ *
+ * @param comp - The component to get the root for.
+ * @return the parent root. An applet if it is a parent,
+ * or the root window. If neither exist, null is returned.
+ */
+ private Component getRoot(Component comp)
+ {
+ Applet app = null;
+
+ while (comp != null)
+ {
+ if (app == null && comp instanceof Window)
+ return comp;
+ else if (comp instanceof Applet)
+ app = (Applet) comp;
+ comp = comp.getParent();
+ }
+
+ return app;
+ }
+
+ /**
* Performs double buffered repainting.
*/
private void paintDoubleBuffered(Rectangle r)
@@ -2166,7 +2193,7 @@ public abstract class JComponent extends Container implements Serializable
RepaintManager rm = RepaintManager.currentManager(this);
// Paint on the offscreen buffer.
- Component root = SwingUtilities.getRoot(this);
+ Component root = getRoot(this);
Image buffer = rm.getOffscreenBuffer(this, root.getWidth(),
root.getHeight());
//Rectangle targetClip = SwingUtilities.convertRectangle(this, r, root);
diff --git a/javax/swing/RepaintManager.java b/javax/swing/RepaintManager.java
index 5887b7769..345c348db 100644
--- a/javax/swing/RepaintManager.java
+++ b/javax/swing/RepaintManager.java
@@ -38,11 +38,13 @@ exception statement from your version. */
package javax.swing;
+import java.applet.Applet;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
+import java.awt.Window;
import java.awt.image.VolatileImage;
import java.util.ArrayList;
import java.util.Collections;
@@ -607,7 +609,7 @@ public class RepaintManager
public Image getOffscreenBuffer(Component component, int proposedWidth,
int proposedHeight)
{
- Component root = SwingUtilities.getRoot(component);
+ Component root = getRoot(component);
Image buffer = (Image) offscreenBuffers.get(root);
if (buffer == null
|| buffer.getWidth(null) < proposedWidth
@@ -622,7 +624,33 @@ public class RepaintManager
}
return buffer;
}
-
+
+ /**
+ * Gets the root of the component given. If a parent of the
+ * component is an instance of Applet, then the applet is
+ * returned. The applet is considered the root for painting.
+ * Otherwise, the root Window is returned if it exists.
+ *
+ * @param comp - The component to get the root for.
+ * @return the parent root. An applet if it is a parent,
+ * or the root window. If neither exist, null is returned.
+ */
+ private Component getRoot(Component comp)
+ {
+ Applet app = null;
+
+ while (comp != null)
+ {
+ if (app == null && comp instanceof Window)
+ return comp;
+ else if (comp instanceof Applet)
+ app = (Applet) comp;
+ comp = comp.getParent();
+ }
+
+ return app;
+ }
+
/**
* Blits the back buffer of the specified root component to the screen. If
* the RepaintManager is currently working on a paint request, the commit
diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java
index 82598ed64..9d8e8df38 100644
--- a/javax/swing/SwingUtilities.java
+++ b/javax/swing/SwingUtilities.java
@@ -376,29 +376,27 @@ public class SwingUtilities
public static Component getRoot(Component comp)
{
Applet app = null;
+ Window win = null;
while (comp != null)
{
- // A Window cannot be in an applet, so
- // the Window returned would be encountered
- // after the applet.
- if (app == null && comp instanceof Window)
- return (Window) comp;
+ if (win == null && comp instanceof Window)
+ win = (Window) comp;
else if (comp instanceof Applet)
app = (Applet) comp;
comp = comp.getParent();
}
+ if (win != null)
+ return win;
return app;
}
/**
- * Return true if a descends from b, in other words if b is an
- * ancestor of a.
- *
+ * Return true if a descends from b, in other words if b is an ancestor of a.
+ *
* @param a The child to search the ancestry of
* @param b The potential ancestor to search for
- *
* @return true if a is a descendent of b, false otherwise
*/
public static boolean isDescendingFrom(Component a, Component b)