diff options
Diffstat (limited to 'libjava/java/awt/Panel.java')
-rw-r--r-- | libjava/java/awt/Panel.java | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/libjava/java/awt/Panel.java b/libjava/java/awt/Panel.java index b84c0d0..dbe3228 100644 --- a/libjava/java/awt/Panel.java +++ b/libjava/java/awt/Panel.java @@ -38,6 +38,7 @@ exception statement from your version. */ package java.awt; +import java.awt.event.PaintEvent; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleRole; @@ -62,6 +63,19 @@ public class Panel extends Container implements Accessible /** The cached accessible context. */ private transient AccessibleContext context; + /** Flag set when the first system-requested paint event is + dispatched. */ + private transient boolean initialSystemUpdateDone; + + /** Flag set when the first application-requested paint event is + consumed. */ + private transient boolean initialUpdateConsumed; + + /* + * The number used to generate the name returned by getName. + */ + private static transient long next_panel_number = 0; + /** * Initializes a new instance of <code>Panel</code> that has a default * layout manager of <code>FlowLayout</code>. @@ -84,6 +98,36 @@ public class Panel extends Container implements Accessible } /** + * Consume initial application-requested paint event if it has not + * already been consumed, and if the initial system-requested paint + * event has not already been handled. Otherwise, call + * super.dispatchEventImpl. These extra steps are required to + * prevent a Panel from being painted twice when it is initially + * shown. + * + * @param e the event to dispatch + */ + void dispatchEventImpl (AWTEvent e) + { + if (e instanceof PaintEvent) + { + if (e.id == PaintEvent.UPDATE) + { + if (!initialUpdateConsumed + && !initialSystemUpdateDone) + { + e.consume (); + initialUpdateConsumed = true; + } + } + else if (e.id == PaintEvent.PAINT) + initialSystemUpdateDone = true; + } + else + super.dispatchEventImpl (e); + } + + /** * Notifies this object to create its native peer. * * @see #isDisplayable() @@ -141,5 +185,20 @@ public class Panel extends Container implements Accessible { return AccessibleRole.PANEL; } - } // class AccessibleAWTPanel -} // class Panel + } + + /** + * Generate a unique name for this panel. + * + * @return A unique name for this panel. + */ + String generateName () + { + return "panel" + getUniqueLong (); + } + + private static synchronized long getUniqueLong () + { + return next_panel_number++; + } +} |