01: package net.xoetrope.awt;
02:
03: import java.awt.Menu;
04: import java.awt.MenuBar;
05: import java.awt.MenuItem;
06:
07: import net.xoetrope.xui.XAppender;
08:
09: /**
10: * A wrapper for menus
11: * <p>Copyright: Copyright (c) Xoetrope Ltd., 2002-2003</p>
12: * @version $Revision: 1.5 $
13: */
14: public class XMenuBar extends MenuBar implements XAppender {
15: public XMenuBar() {
16: }
17:
18: /**
19: * Do any final setup needed
20: */
21: public void setup() {
22: net.xoetrope.awt.XApplet.setMenuBar(this );
23: }
24:
25: /**
26: * Appends the object o to this item
27: * @param o the appended item
28: * @param name
29: */
30: public void append(Object o, String name) {
31: add((Menu) o);
32: }
33:
34: /**
35: * Get a child object by name
36: * @param name
37: * @return the child
38: */
39: public Object getObject(String name) {
40: int menuCount = getMenuCount();
41: for (int i = 0; i < menuCount; i++) {
42: Menu menu = getMenu(i);
43: int itemCount = menu.getItemCount();
44: for (int j = 0; j < itemCount; j++) {
45: MenuItem item = menu.getItem(j);
46: if (item.getName().compareTo(name) == 0)
47: return item;
48: }
49: }
50: return null;
51: }
52: }
|