aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt/Menu.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/awt/Menu.java')
-rw-r--r--libjava/java/awt/Menu.java126
1 files changed, 114 insertions, 12 deletions
diff --git a/libjava/java/awt/Menu.java b/libjava/java/awt/Menu.java
index af1c4c8..34dd600 100644
--- a/libjava/java/awt/Menu.java
+++ b/libjava/java/awt/Menu.java
@@ -8,26 +8,128 @@ details. */
package java.awt;
-/* A very incomplete placeholder. */
+import java.util.Vector;
+
+/* Status: Incomplete. */
public class Menu extends MenuItem implements MenuContainer
{
- public Menu (String label)
+ // Fields from the serialization spec. Decalare others "transient".
+ Vector items = new Vector();
+ boolean tearOff;
+ boolean isHelpMenu;
+ int menuSerializedDataVersion;
+
+ static final MenuItem separator = new MenuItem("-");
+
+ public Menu()
+ {
+ this(null, false);
+ }
+
+ public Menu(String label)
{
- super(label); // ???
- throw new Error ("java.awt.Menu: not implemented");
+ this(label, false);
+ }
+
+ public Menu(String label, boolean tearOff)
+ {
+ super(label);
+ this.tearOff = tearOff;
}
- public void add (String label)
- { /* FIXME */ }
+ public void addNotify()
+ {
+ // FIXME
+ }
+
+ public void removeNotify()
+ {
+ // FIXME
+ }
- public synchronized MenuItem add (MenuItem item)
+ public boolean isTearOff()
{
- /* FIXME */
- return item;
+ return tearOff;
}
- public Font getFont() { return null; } // FIXME
- public boolean postEvent(Event evt) { return false; } // FIXME
- public void remove(MenuComponent comp) { } // FIXME
+ public int getItemCount()
+ {
+ return items.size();
+ }
+
+ /** @deprecated Use getItemCount() instead. */
+ public int countItems()
+ {
+ return getItemCount();
+ }
+
+ public MenuItem getItem(int index)
+ {
+ return (MenuItem) items.elementAt(index);
+ }
+
+ public synchronized MenuItem add(MenuItem mi)
+ {
+ items.addElement(mi);
+ if (mi.parent != null)
+ {
+ mi.parent.remove(mi);
+ }
+ mi.parent = this;
+ return mi;
+ }
+
+ public void add(String label)
+ {
+ MenuItem mi = new MenuItem(label);
+ this.add(mi);
+ }
+
+ public synchronized void insert(MenuItem menuitem, int index)
+ {
+ if (index < 0)
+ throw new IllegalArgumentException();
+ items.insertElementAt(menuitem, index);
+ }
+
+ public void insert(String label, int index)
+ {
+ MenuItem mi = new MenuItem(label);
+ this.insert(mi, index);
+ }
+
+ public void addSeparator()
+ {
+ this.add(separator);
+ }
+
+ public void insertSeparator(int index)
+ {
+ this.insert(separator, index);
+ }
+
+ public synchronized void remove(int index)
+ {
+ items.removeElementAt(index);
+ }
+
+ public synchronized void remove(MenuComponent item)
+ {
+ items.removeElement(item);
+ }
+
+ public synchronized void removeAll()
+ {
+ items.removeAllElements();
+ }
+
+ public String paramString()
+ {
+ return getName() + ",label" + label + ",tearOff=" + tearOff +
+ ",isHelpMenu=" + isHelpMenu;
+ }
+
+ // Accessibility API not yet implemented.
+ // public AccessibleContext getAccessibleContext()
}