diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2006-08-14 23:12:35 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2006-08-14 23:12:35 +0000 |
commit | ac1ed908de999523efc36f38e69bca1aadfe0808 (patch) | |
tree | 97037d2c09c8384d80531f67ec36a01205df6bdb /libjava/classpath/javax/swing/JMenu.java | |
parent | abab460491408e05ea93fb85e1975296a87df504 (diff) | |
download | gcc-ac1ed908de999523efc36f38e69bca1aadfe0808.zip gcc-ac1ed908de999523efc36f38e69bca1aadfe0808.tar.gz gcc-ac1ed908de999523efc36f38e69bca1aadfe0808.tar.bz2 |
Imported GNU Classpath 0.92
2006-08-14 Mark Wielaard <mark@klomp.org>
Imported GNU Classpath 0.92
* HACKING: Add more importing hints. Update automake version
requirement.
* configure.ac (gconf-peer): New enable AC argument.
Add --disable-gconf-peer and --enable-default-preferences-peer
to classpath configure when gconf is disabled.
* scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
gnu/java/awt/dnd/peer/gtk to bc. Classify
gnu/java/security/Configuration.java as generated source file.
* gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
gnu/java/lang/management/VMThreadMXBeanImpl.java,
gnu/java/lang/management/VMMemoryMXBeanImpl.java,
gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
classes.
* java/lang/management/VMManagementFactory.java: Likewise.
* java/net/VMURLConnection.java: Likewise.
* gnu/java/nio/VMChannel.java: Likewise.
* java/lang/Thread.java (getState): Add stub implementation.
* java/lang/Class.java (isEnum): Likewise.
* java/lang/Class.h (isEnum): Likewise.
* gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.
* javax/naming/spi/NamingManager.java: New override for StackWalker
functionality.
* configure, sources.am, Makefile.in, gcj/Makefile.in,
include/Makefile.in, testsuite/Makefile.in: Regenerated.
From-SVN: r116139
Diffstat (limited to 'libjava/classpath/javax/swing/JMenu.java')
-rw-r--r-- | libjava/classpath/javax/swing/JMenu.java | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/libjava/classpath/javax/swing/JMenu.java b/libjava/classpath/javax/swing/JMenu.java index 02cb20e..0840509 100644 --- a/libjava/classpath/javax/swing/JMenu.java +++ b/libjava/classpath/javax/swing/JMenu.java @@ -40,6 +40,7 @@ package javax.swing; import java.awt.Component; import java.awt.Point; +import java.awt.PopupMenu; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; @@ -74,7 +75,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement private static final long serialVersionUID = 4227225638931828014L; /** A Popup menu associated with this menu, which pops up when menu is selected */ - private JPopupMenu popupMenu = new JPopupMenu(); + private JPopupMenu popupMenu = null; /** Whenever menu is selected or deselected the MenuEvent is fired to menu's registered listeners. */ @@ -98,6 +99,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement { super(); setOpaque(false); + setDelay(200); } /** @@ -108,8 +110,10 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement public JMenu(String text) { super(text); + popupMenu = new JPopupMenu(); popupMenu.setInvoker(this); setOpaque(false); + setDelay(200); } /** @@ -122,8 +126,10 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement { super(action); createActionChangeListener(this); + popupMenu = new JPopupMenu(); popupMenu.setInvoker(this); setOpaque(false); + setDelay(200); } /** @@ -137,6 +143,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement { // FIXME: tearoff not implemented this(text); + setDelay(200); } /** @@ -148,7 +155,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public JMenuItem add(JMenuItem item) { - return popupMenu.add(item); + return getPopupMenu().add(item); } /** @@ -160,7 +167,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public Component add(Component component) { - popupMenu.insert(component, -1); + getPopupMenu().insert(component, -1); return component; } @@ -174,7 +181,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public Component add(Component component, int index) { - return popupMenu.add(component, index); + return getPopupMenu().add(component, index); } /** @@ -186,7 +193,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public JMenuItem add(String text) { - return popupMenu.add(text); + return getPopupMenu().add(text); } /** @@ -198,7 +205,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public JMenuItem add(Action action) { - return popupMenu.add(action); + return getPopupMenu().add(action); } /** @@ -209,7 +216,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public void remove(JMenuItem item) { - popupMenu.remove(item); + getPopupMenu().remove(item); } /** @@ -219,7 +226,11 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public void remove(int index) { - popupMenu.remove(index); + if (index < 0 || (index > 0 && getMenuComponentCount() == 0)) + throw new IllegalArgumentException(); + + if (getMenuComponentCount() > 0) + popupMenu.remove(index); } /** @@ -229,8 +240,9 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public void remove(Component component) { - int index = popupMenu.getComponentIndex(component); - popupMenu.remove(index); + int index = getPopupMenu().getComponentIndex(component); + if (index >= 0) + getPopupMenu().remove(index); } /** @@ -238,7 +250,8 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public void removeAll() { - popupMenu.removeAll(); + if (popupMenu != null) + popupMenu.removeAll(); } /** @@ -267,7 +280,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement if (index < 0) throw new IllegalArgumentException("index less than zero"); - popupMenu.insert(item, index); + getPopupMenu().insert(item, index); return item; } @@ -381,7 +394,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement super.setSelected(false); super.setArmed(false); fireMenuDeselected(); - popupMenu.setVisible(false); + getPopupMenu().setVisible(false); } } @@ -404,7 +417,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public boolean isPopupMenuVisible() { - return popupMenu.isVisible(); + return getPopupMenu().isVisible(); } /** @@ -415,7 +428,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement public void setPopupMenuVisible(boolean popup) { if (getModel().isEnabled()) - popupMenu.setVisible(popup); + getPopupMenu().setVisible(popup); } /** @@ -530,6 +543,9 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement if (index < 0) throw new IllegalArgumentException("index less than 0"); + if (getItemCount() == 0) + return null; + Component c = popupMenu.getComponentAtIndex(index); if (c instanceof JMenuItem) @@ -558,7 +574,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement public boolean isTearOff() { // NOT YET IMPLEMENTED - return false; + throw new Error("The method isTearOff() has not yet been implemented."); } /** @@ -568,7 +584,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public int getMenuComponentCount() { - return popupMenu.getComponentCount(); + return getPopupMenu().getComponentCount(); } /** @@ -581,6 +597,9 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public Component getMenuComponent(int index) { + if (getPopupMenu() == null || getMenuComponentCount() == 0) + return null; + return (Component) popupMenu.getComponentAtIndex(index); } @@ -591,7 +610,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public Component[] getMenuComponents() { - return popupMenu.getComponents(); + return getPopupMenu().getComponents(); } /** @@ -626,6 +645,11 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement */ public JPopupMenu getPopupMenu() { + if (popupMenu == null) + { + popupMenu = new JPopupMenu(); + popupMenu.setInvoker(this); + } return popupMenu; } |