diff options
Diffstat (limited to 'libjava/classpath/javax/swing/JComponent.java')
-rw-r--r-- | libjava/classpath/javax/swing/JComponent.java | 73 |
1 files changed, 56 insertions, 17 deletions
diff --git a/libjava/classpath/javax/swing/JComponent.java b/libjava/classpath/javax/swing/JComponent.java index d916d05..b217bc7 100644 --- a/libjava/classpath/javax/swing/JComponent.java +++ b/libjava/classpath/javax/swing/JComponent.java @@ -760,13 +760,6 @@ public abstract class JComponent extends Container implements Serializable public static final int WHEN_IN_FOCUSED_WINDOW = 2; /** - * Indicates if this component is completely dirty or not. This is used - * by the RepaintManager's - * {@link RepaintManager#isCompletelyDirty(JComponent)} method. - */ - boolean isCompletelyDirty = false; - - /** * Indicates if the opaque property has been set by a client program or by * the UI. * @@ -1763,11 +1756,6 @@ public abstract class JComponent extends Container implements Serializable paintComponent(g2); paintBorder(g2); paintChildren(g2); - Rectangle clip = g2.getClipBounds(); - if (clip == null - || (clip.x == 0 && clip.y == 0 && clip.width == getWidth() - && clip.height == getHeight())) - RepaintManager.currentManager(this).markCompletelyClean(this); } } } @@ -2373,6 +2361,19 @@ public abstract class JComponent extends Container implements Serializable } } + /** + * Returns the input map associated with this component for the given + * state/condition. + * + * @param condition the state (one of {@link #WHEN_FOCUSED}, + * {@link #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT} and + * {@link #WHEN_IN_FOCUSED_WINDOW}). + * + * @return The input map. + * @throws IllegalArgumentException if <code>condition</code> is not one of + * the specified values. + * @since 1.3 + */ public final InputMap getInputMap(int condition) { enableEvents(AWTEvent.KEY_EVENT_MASK); @@ -2395,10 +2396,20 @@ public abstract class JComponent extends Container implements Serializable case UNDEFINED_CONDITION: default: - return null; + throw new IllegalArgumentException("Invalid 'condition' argument: " + + condition); } } + /** + * Returns the input map associated with this component for the + * {@link #WHEN_FOCUSED} state. + * + * @return The input map. + * + * @since 1.3 + * @see #getInputMap(int) + */ public final InputMap getInputMap() { return getInputMap(WHEN_FOCUSED); @@ -3554,6 +3565,7 @@ public abstract class JComponent extends Container implements Serializable Rectangle currentClip = clip; Component found = this; Container parent = this; + while (parent != null && !(parent instanceof Window)) { Container newParent = parent.getParent(); @@ -3569,15 +3581,42 @@ public abstract class JComponent extends Container implements Serializable parent = newParent; continue; } - // If the parent is not optimizedDrawingEnabled, we must paint the - // parent. + + // If the parent is not optimizedDrawingEnabled, we must check if the + // parent or some neighbor overlaps the current clip. + + // This is the current clip converted to the parent's coordinate + // system. TODO: We can do this more efficiently by succesively + // cumulating the parent-child translations. Rectangle target = SwingUtilities.convertRectangle(found, currentClip, newParent); - found = newParent; - currentClip = target; + + // We have an overlap if either: + // - The new parent itself doesn't completely cover the clip + // (this can be the case with viewports). + // - If some higher-level (than the current) children of the new parent + // intersect the target rectangle. + Rectangle parentRect = SwingUtilities.getLocalBounds(newParent); + boolean haveOverlap = + ! SwingUtilities.isRectangleContainingRectangle(parentRect, target); + if (! haveOverlap) + { + Component[] children = newParent.getComponents(); + for (int i = 0; children[i] != parent && !haveOverlap; i++) + { + Rectangle childRect = children[i].getBounds(); + haveOverlap = target.intersects(childRect); + } + } + if (haveOverlap) + { + found = newParent; + currentClip = target; + } parent = newParent; } + //System.err.println("overlapfree parent: " + found); return found; } |