aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/java/awt/Menu.java
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2006-03-10 21:46:48 +0000
committerMark Wielaard <mark@gcc.gnu.org>2006-03-10 21:46:48 +0000
commit8aa540d2f783474d1d2e06f16744bf67b9c1facc (patch)
treeea38c56431c5d4528fb54254c3f8e50f517bede3 /libjava/classpath/java/awt/Menu.java
parent27079765d00123f8e53d0e1ef7f9d46559266e6d (diff)
downloadgcc-8aa540d2f783474d1d2e06f16744bf67b9c1facc.zip
gcc-8aa540d2f783474d1d2e06f16744bf67b9c1facc.tar.gz
gcc-8aa540d2f783474d1d2e06f16744bf67b9c1facc.tar.bz2
Imported GNU Classpath 0.90
Imported GNU Classpath 0.90 * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore. * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant. * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5. * java/lang/Math.java: New override file. * java/lang/Character.java: Merged from Classpath. (start, end): Now 'int's. (canonicalName): New field. (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants. (UnicodeBlock): Added argument. (of): New overload. (forName): New method. Updated unicode blocks. (sets): Updated. * sources.am: Regenerated. * Makefile.in: Likewise. From-SVN: r111942
Diffstat (limited to 'libjava/classpath/java/awt/Menu.java')
-rw-r--r--libjava/classpath/java/awt/Menu.java59
1 files changed, 39 insertions, 20 deletions
diff --git a/libjava/classpath/java/awt/Menu.java b/libjava/classpath/java/awt/Menu.java
index 13ebb52..6daec72 100644
--- a/libjava/classpath/java/awt/Menu.java
+++ b/libjava/classpath/java/awt/Menu.java
@@ -1,5 +1,5 @@
/* Menu.java -- A Java AWT Menu
- Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -220,15 +220,16 @@ getItem(int index)
public MenuItem
add(MenuItem item)
{
+ MenuContainer parent = item.getParent();
+ if (parent != null)
+ parent.remove(item);
+
items.addElement(item);
- if (item.parent != null)
- {
- item.parent.remove(item);
- }
- item.parent = this;
+ item.setParent(this);
if (peer != null)
{
+ item.addNotify();
MenuPeer mp = (MenuPeer) peer;
mp.addItem(item);
}
@@ -266,26 +267,33 @@ insert(MenuItem item, int index)
if (index < 0)
throw new IllegalArgumentException("Index is less than zero");
- MenuPeer peer = (MenuPeer) getPeer();
- if (peer == null)
- return;
-
int count = getItemCount ();
if (index >= count)
- peer.addItem (item);
+ add(item);
else
{
+ MenuContainer parent = item.getParent();
+ if (parent != null)
+ parent.remove(item);
+
+ items.insertElementAt(item, index);
+ item.setParent(this);
+
+ MenuPeer peer = (MenuPeer) getPeer();
+ if (peer == null)
+ return;
+
for (int i = count - 1; i >= index; i--)
- peer.delItem (i);
+ peer.delItem(i);
- peer.addItem (item);
+ item.addNotify();
+ peer.addItem(item);
for (int i = index; i < count; i++)
- peer.addItem ((MenuItem) items.elementAt (i));
+ peer.addItem((MenuItem) items.elementAt (i));
}
- items.insertElementAt(item, index);
}
/*************************************************************************/
@@ -344,11 +352,15 @@ insertSeparator(int index)
public synchronized void
remove(int index)
{
- items.removeElementAt(index);
+ MenuItem item = (MenuItem) items.remove(index);
- MenuPeer mp = (MenuPeer)getPeer();
+ MenuPeer mp = (MenuPeer) getPeer();
if (mp != null)
- mp.delItem(index);
+ {
+ mp.delItem(index);
+ item.removeNotify();
+ }
+ item.setParent(null);
}
/*************************************************************************/
@@ -393,14 +405,21 @@ removeAll()
public void
addNotify()
{
+ MenuPeer peer = (MenuPeer) getPeer();
if (peer == null)
- peer = getToolkit().createMenu(this);
+ {
+ peer = getToolkit().createMenu(this);
+ setPeer(peer);
+ }
+
Enumeration e = items.elements();
while (e.hasMoreElements())
{
MenuItem mi = (MenuItem)e.nextElement();
mi.addNotify();
- }
+ peer.addItem(mi);
+ }
+
super.addNotify ();
}