You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2011/06/14 15:00:15 UTC

svn commit: r1135541 - /pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java

Author: gbrown
Date: Tue Jun 14 13:00:14 2011
New Revision: 1135541

URL: http://svn.apache.org/viewvc?rev=1135541&view=rev
Log:
Fix bug in removing menu bar items.

Modified:
    pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java?rev=1135541&r1=1135540&r2=1135541&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java Tue Jun 14 13:00:14 2011
@@ -72,7 +72,8 @@ public class MenuBar extends Container {
 
         @Override
         protected void setParent(Container parent) {
-            if (!(parent instanceof MenuBar)) {
+            if (parent != null
+                && !(parent instanceof MenuBar)) {
                 throw new IllegalArgumentException("Parent must be an instance of "
                     + MenuBar.class.getName());
             }
@@ -310,6 +311,20 @@ public class MenuBar extends Container {
         }
     }
 
+    @Override
+    public Sequence<Component> remove(int index, int count) {
+        for (int i = index, n = index + count; i < n; i++) {
+            Component component = get(i);
+
+            if (items.indexOf((Item)component) >= 0) {
+                throw new UnsupportedOperationException();
+            }
+        }
+
+        // Call the base method to remove the components
+        return super.remove(index, count);
+    }
+
     public void activateNextItem() {
         int n = items.getLength();