396
397 /* Add the removed items back to the menu, they are
398 already in the correct order in the temp vector.
399 */
400 for (int i = 0; i < tempItems.size() ; i++) {
401 add(tempItems.elementAt(i));
402 }
403 }
404 }
405
406 /**
407 * Removes the menu item at the specified index from this menu.
408 * @param index the position of the item to be removed.
409 */
410 public void remove(int index) {
411 synchronized (getTreeLock()) {
412 MenuItem mi = getItem(index);
413 items.removeElementAt(index);
414 MenuPeer peer = (MenuPeer)this.peer;
415 if (peer != null) {
416 mi.removeNotify();
417 mi.parent = null;
418 peer.delItem(index);
419 }
420 }
421 }
422
423 /**
424 * Removes the specified menu item from this menu.
425 * @param item the item to be removed from the menu.
426 * If <code>item</code> is <code>null</code>
427 * or is not in this menu, this method does
428 * nothing.
429 */
430 public void remove(MenuComponent item) {
431 synchronized (getTreeLock()) {
432 int index = items.indexOf(item);
433 if (index >= 0) {
434 remove(index);
435 }
436 }
437 }
438
|
396
397 /* Add the removed items back to the menu, they are
398 already in the correct order in the temp vector.
399 */
400 for (int i = 0; i < tempItems.size() ; i++) {
401 add(tempItems.elementAt(i));
402 }
403 }
404 }
405
406 /**
407 * Removes the menu item at the specified index from this menu.
408 * @param index the position of the item to be removed.
409 */
410 public void remove(int index) {
411 synchronized (getTreeLock()) {
412 MenuItem mi = getItem(index);
413 items.removeElementAt(index);
414 MenuPeer peer = (MenuPeer)this.peer;
415 if (peer != null) {
416 peer.delItem(index);
417 mi.removeNotify();
418 mi.parent = null;
419 }
420 }
421 }
422
423 /**
424 * Removes the specified menu item from this menu.
425 * @param item the item to be removed from the menu.
426 * If <code>item</code> is <code>null</code>
427 * or is not in this menu, this method does
428 * nothing.
429 */
430 public void remove(MenuComponent item) {
431 synchronized (getTreeLock()) {
432 int index = items.indexOf(item);
433 if (index >= 0) {
434 remove(index);
435 }
436 }
437 }
438
|