summaryrefslogtreecommitdiff
path: root/libjava/classpath/java/awt/Container.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/awt/Container.java')
-rw-r--r--libjava/classpath/java/awt/Container.java40
1 files changed, 38 insertions, 2 deletions
diff --git a/libjava/classpath/java/awt/Container.java b/libjava/classpath/java/awt/Container.java
index 2419a7bd24a..85a68ce13c2 100644
--- a/libjava/classpath/java/awt/Container.java
+++ b/libjava/classpath/java/awt/Container.java
@@ -457,8 +457,44 @@ public class Container extends Component
{
synchronized (getTreeLock ())
{
- while (ncomponents > 0)
- remove(0);
+ // In order to allow the same bad tricks to be used as in RI
+ // this code has to stay exactly that way: In a real-life app
+ // a Container subclass implemented its own vector for
+ // subcomponents, supplied additional addXYZ() methods
+ // and overrode remove(int) and removeAll (the latter calling
+ // super.removeAll() ).
+ // By doing it this way, user code cannot prevent the correct
+ // removal of components.
+ for ( int index = 0; index < ncomponents; index++)
+ {
+ Component r = component[index];
+
+ ComponentListener[] list = r.getComponentListeners();
+ for (int j = 0; j < list.length; j++)
+ r.removeComponentListener(list[j]);
+
+ r.removeNotify();
+
+ if (layoutMgr != null)
+ layoutMgr.removeLayoutComponent(r);
+
+ r.parent = null;
+
+ if (isShowing ())
+ {
+ // Post event to notify of removing the component.
+ ContainerEvent ce
+ = new ContainerEvent(this,
+ ContainerEvent.COMPONENT_REMOVED,
+ r);
+
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+
+ invalidate();
+
+ ncomponents = 0;
}
}