java.awt
Class MenuItem
- Accessible, Serializable
This class represents an item in a menu.
MenuItem() - Initializes a new instance of
MenuItem with no label
and no shortcut.
|
MenuItem(String label) - Initializes a new instance of
MenuItem with the specified
label and no shortcut.
|
MenuItem(String label, MenuShortcut shortcut) - Initializes a new instance of
MenuItem with the specified
label and shortcut.
|
dispatchEvent , getAccessibleContext , getFont , getName , getParent , getPeer , getTreeLock , paramString , postEvent , processEvent , removeNotify , setFont , setName , toString |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
MenuItem
public MenuItem()
Initializes a new instance of MenuItem
with no label
and no shortcut.
MenuItem
public MenuItem(String label)
Initializes a new instance of MenuItem
with the specified
label and no shortcut.
label
- The label for this menu item.
MenuItem
public MenuItem(String label,
MenuShortcut shortcut)
Initializes a new instance of MenuItem
with the specified
label and shortcut.
label
- The label for this menu item.shortcut
- The shortcut for this menu item.
addActionListener
public void addActionListener(ActionListener listener)
Adds the specified listener to the list of registered action listeners
for this component.
listener
- The listener to add.
addNotify
public void addNotify()
Creates the native peer for this object.
deleteShortcut
public void deleteShortcut()
Deletes the shortcut for this menu item if one exists. This must be
done before the native peer is created.
disable
public void disable()
This method is deprecated in favor of setEnabled()
.
Disables this menu item.
disableEvents
protected final void disableEvents(long events)
Disables the specified events.
events
- The events to enable, which should be the bit masks
from AWTEvent
.
enable
public void enable()
This method is deprecated in favor of setEnabled()
.
Enables this menu item.
enable
public void enable(boolean enabled)
This method is deprecated in favor of setEnabled()
.
Sets the enabled status of this menu item.
enabled
- true
to enable this menu item,
false
otherwise.
enableEvents
protected final void enableEvents(long events)
Enables the specified events. This is done automatically when a
listener is added and does not normally need to be done by
application code.
events
- The events to enable, which should be the bit masks
from AWTEvent
.
extends EventListener> T[] getListeners
public extends EventListener> T[] getListeners(Class listenerType)
Returns all registered EventListers of the given listenerType.
listenerType must be a subclass of EventListener, or a
ClassClassException is thrown.
getActionCommand
public String getActionCommand()
Returns the name of the action command in the action events
generated by this menu item.
getLabel
public String getLabel()
Returns the label for this menu item, which may be null
.
- The label for this menu item.
getShortcut
public MenuShortcut getShortcut()
Returns the shortcut for this menu item, which may be null
.
- The shortcut for this menu item.
isEnabled
public boolean isEnabled()
Tests whether or not this menu item is enabled.
true
if this menu item is enabled, false
otherwise.
processActionEvent
protected void processActionEvent(ActionEvent event)
Processes the specified event by dispatching it to any registered listeners.
event
- The event to process.
setActionCommand
public void setActionCommand(String actionCommand)
Sets the name of the action command in the action events generated by
this menu item.
actionCommand
- The new action command name.
setEnabled
public void setEnabled(boolean enabled)
Sets the enabled status of this menu item.
enabled
- true
to enable this menu item,
false
otherwise.
setLabel
public void setLabel(String label)
This method sets the label for this menu to the specified value.
label
- The new label for this menu item.
setShortcut
public void setShortcut(MenuShortcut shortcut)
Sets the shortcut for this menu item to the specified value. This
must be done before the native peer is created.
shortcut
- The new shortcut for this menu item.
MenuItem.java -- An item in a menu
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.