|
Modifier and Type |
Method and Description |
|
add |
Adds the specified menu item to this menu.
|
|
add |
void add(java.lang.String label)
Adds an item with the specified label to this menu.
|
|
addActionListener |
void addActionListener(ActionListener l)
Adds the specified action listener to receive action events
from this menu item.
|
|
addNotify |
void addNotify()
Creates the menu's peer.
public void addNotify()
-
Creates the menu's peer. The peer allows us to modify the
appearance of the menu without changing its functionality.
- Overrides:
addNotify in class MenuItem
|
|
addSeparator |
void addSeparator()
Adds a separator line, or a hypen, to the menu at the current position.
public void addSeparator()
-
Adds a separator line, or a hypen, to the menu at the current position.
- See Also:
insertSeparator(int)
|
|
countItems |
int countItems()
Deprecated. As of JDK version 1.1,
replaced by getItemCount() .
@Deprecated
public int countItems()
Deprecated. As of JDK version 1.1,
replaced by getItemCount() .
|
|
deleteShortcut |
void deleteShortcut()
Delete any MenuShortcut object associated
with this menu item.
public void deleteShortcut()
-
Delete any MenuShortcut object associated
with this menu item.
- Since:
- JDK1.1
|
|
disable |
void disable()
Deprecated. As of JDK version 1.1,
replaced by setEnabled(boolean) .
@Deprecated
public void disable()
Deprecated. As of JDK version 1.1,
replaced by setEnabled(boolean) .
|
|
disableEvents |
protected void disableEvents(long eventsToDisable)
Disables event delivery to this menu item for events
defined by the specified event mask parameter.
|
|
dispatchEvent |
void dispatchEvent(AWTEvent e)
Delivers an event to this component or one of its sub components.
public final void dispatchEvent( AWTEvent e)
-
Delivers an event to this component or one of its sub components.
- Parameters:
e - the event
|
|
enable |
void enable()
Deprecated. As of JDK version 1.1,
replaced by setEnabled(boolean) .
@Deprecated
public void enable()
Deprecated. As of JDK version 1.1,
replaced by setEnabled(boolean) .
|
|
enable |
void enable(boolean b)
Deprecated. As of JDK version 1.1,
replaced by setEnabled(boolean) .
@Deprecated
public void enable(boolean b)
Deprecated. As of JDK version 1.1,
replaced by setEnabled(boolean) .
|
|
enableEvents |
protected void enableEvents(long eventsToEnable)
Enables event delivery to this menu item for events
to be defined by the specified event mask parameter
protected final void enableEvents(long eventsToEnable)
-
Enables event delivery to this menu item for events
to be defined by the specified event mask parameter
Since event types are automatically enabled when a listener for
that type is added to the menu item, this method only needs
to be invoked by subclasses of MenuItem which desire to
have the specified event types delivered to processEvent
regardless of whether a listener is registered.
- Parameters:
eventsToEnable - the event mask defining the event types- Since:
- JDK1.1
- See Also:
MenuItem.processEvent(java.awt.AWTEvent) ,
MenuItem.disableEvents(long) ,
Component.enableEvents(long)
|
|
getAccessibleContext |
javax.accessibility.AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this Menu.
public javax.accessibility.AccessibleContext getAccessibleContext()
-
Gets the AccessibleContext associated with this Menu.
For menus, the AccessibleContext takes the form of an
AccessibleAWTMenu.
A new AccessibleAWTMenu instance is created if necessary.
- Specified by:
getAccessibleContext in interface javax.accessibility.Accessible
- Overrides:
getAccessibleContext in class MenuItem
- Returns:
- an AccessibleAWTMenu that serves as the
AccessibleContext of this Menu
- Since:
- 1.3
|
|
getActionCommand |
java.lang.String getActionCommand()
Gets the command name of the action event that is fired
by this menu item.
|
|
getActionListeners |
Returns an array of all the action listeners
registered on this menu item.
|
|
getFont |
Gets the font used for this menu component.
|
|
getItem |
Gets the item located at the specified index of this menu.
-
Gets the item located at the specified index of this menu.
- Parameters:
index - the position of the item to be returned.
- Returns:
- the item located at the specified index.
|
|
getItemCount |
int getItemCount()
Get the number of items in this menu.
public int getItemCount()
-
Get the number of items in this menu.
- Returns:
- the number of items in this menu.
- Since:
- JDK1.1
|
|
getLabel |
java.lang.String getLabel()
Gets the label for this menu item.
public java.lang.String getLabel()
-
Gets the label for this menu item.
- Returns:
- the label of this menu item, or
null
if this menu item has no label. - Since:
- JDK1.0
- See Also:
MenuItem.setLabel(java.lang.String)
|
|
getListeners |
<T extends java.util.EventListener> T[] getListeners(java.lang.Class<T> listenerType)
Returns an array of all the objects currently registered
as FooListener s
upon this MenuItem .
public <T extends java.util.EventListener> T[] getListeners(java.lang.Class<T> listenerType)
-
Returns an array of all the objects currently registered
as FooListener s
upon this MenuItem .
FooListener s are registered using the
addFooListener method.
You can specify the listenerType argument
with a class literal, such as
FooListener.class .
For example, you can query a
MenuItem m
for its action listeners with the following code:
ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));
If no such listeners exist, this method returns an empty array.
- Parameters:
listenerType - the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener
- Returns:
- an array of all objects registered as
FooListener s on this menu item,
or an empty array if no such
listeners have been added
- Throws:
java.lang.ClassCastException - if listenerType
doesn't specify a class or interface that implements
java.util.EventListener - Since:
- 1.3
- See Also:
MenuItem.getActionListeners()
|
|
getName |
java.lang.String getName()
Gets the name of the menu component.
|
|
getParent |
Returns the parent container for this menu component.
-
Returns the parent container for this menu component.
- Returns:
- the menu component containing this menu component,
or
null if this menu component
is the outermost component, the menu bar itself
|
|
getPeer |
java.awt.peer.MenuComponentPeer getPeer()
Deprecated. As of JDK version 1.1,
programs should not directly manipulate peers.
@Deprecated
public java.awt.peer.MenuComponentPeer getPeer()
Deprecated. As of JDK version 1.1,
programs should not directly manipulate peers.
|
|
getShortcut |
Get the MenuShortcut object associated with this
menu item,
-
Get the MenuShortcut object associated with this
menu item,
- Returns:
- the menu shortcut associated with this menu item,
or
null if none has been specified. - Since:
- JDK1.1
- See Also:
MenuItem.setShortcut(java.awt.MenuShortcut)
|
|
getTreeLock |
protected java.lang.Object getTreeLock()
Gets this component's locking object (the object that owns the thread
sychronization monitor) for AWT component-tree and layout
operations.
protected final java.lang.Object getTreeLock()
-
Gets this component's locking object (the object that owns the thread
sychronization monitor) for AWT component-tree and layout
operations.
- Returns:
- this component's locking object
|
|
insert |
void insert(MenuItem menuitem,
int index)
Inserts a menu item into this menu
at the specified position.
public void insert( MenuItem menuitem,
int index)
-
Inserts a menu item into this menu
at the specified position.
- Parameters:
menuitem - the menu item to be inserted.index - the position at which the menu
item should be inserted.
- Throws:
java.lang.IllegalArgumentException - if the value of
index is less than zero- Since:
- JDK1.1
- See Also:
add(java.lang.String) ,
add(java.awt.MenuItem)
|
|
insert |
void insert(java.lang.String label,
int index)
Inserts a menu item with the specified label into this menu
at the specified position.
public void insert(java.lang.String label,
int index)
-
Inserts a menu item with the specified label into this menu
at the specified position. This is a convenience method for
insert(menuItem, index) .
- Parameters:
label - the text on the itemindex - the position at which the menu item
should be inserted
- Throws:
java.lang.IllegalArgumentException - if the value of
index is less than zero- Since:
- JDK1.1
- See Also:
add(java.lang.String) ,
add(java.awt.MenuItem)
|
|
insertSeparator |
void insertSeparator(int index)
Inserts a separator at the specified position.
public void insertSeparator(int index)
-
Inserts a separator at the specified position.
- Parameters:
index - the position at which the
menu separator should be inserted.
- Throws:
java.lang.IllegalArgumentException - if the value of
index is less than 0.- Since:
- JDK1.1
- See Also:
addSeparator()
|
|
isEnabled |
boolean isEnabled()
Checks whether this menu item is enabled.
|
|
isTearOff |
boolean isTearOff()
Indicates whether this menu is a tear-off menu.
public boolean isTearOff()
-
Indicates whether this menu is a tear-off menu.
Tear-off functionality may not be supported by all
implementations of AWT. If a particular implementation doesn't
support tear-off menus, this value is silently ignored.
- Returns:
true if this is a tear-off menu;
false otherwise.
|
|
paramString |
java.lang.String paramString()
Returns a string representing the state of this Menu .
public java.lang.String paramString()
-
Returns a string representing the state of this Menu .
This method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null .
- Overrides:
paramString in class MenuItem
- Returns:
- the parameter string of this menu
|
|
postEvent |
boolean postEvent(Event evt)
@Deprecated
public boolean postEvent( Event evt)
Deprecated. As of JDK version 1.1, replaced by dispatchEvent .
-
Posts the specified event to the menu.
This method is part of the Java 1.0 event system
and it is maintained only for backwards compatibility.
Its use is discouraged, and it may not be supported
in the future.
- Parameters:
evt - the event which is to take place
|
|
processActionEvent |
protected void processActionEvent(ActionEvent e)
Processes action events occurring on this menu item,
by dispatching them to any registered
ActionListener objects.
-
Processes action events occurring on this menu item,
by dispatching them to any registered
ActionListener objects.
This method is not called unless action events are
enabled for this component. Action events are enabled
when one of the following occurs:
- An
ActionListener object is registered
via addActionListener .
- Action events are enabled via
enableEvents .
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
- Parameters:
e - the action event- Since:
- JDK1.1
- See Also:
ActionEvent ,
ActionListener ,
MenuItem.enableEvents(long)
|
|
processEvent |
protected void processEvent(AWTEvent e)
Processes events on this menu item.
-
Processes events on this menu item. If the event is an
instance of ActionEvent , it invokes
processActionEvent , another method
defined by MenuItem .
Currently, menu items only support action events.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
- Overrides:
processEvent in class MenuComponent
- Parameters:
e - the event- Since:
- JDK1.1
- See Also:
MenuItem.processActionEvent(java.awt.event.ActionEvent)
|
|
remove |
void remove(int index)
Removes the menu item at the specified index from this menu.
public void remove(int index)
-
Removes the menu item at the specified index from this menu.
- Parameters:
index - the position of the item to be removed.
|
|
remove |
void remove(MenuComponent item)
Removes the specified menu item from this menu.
-
Removes the specified menu item from this menu.
- Specified by:
remove in interface MenuContainer
- Parameters:
item - the item to be removed from the menu.
If item is null
or is not in this menu, this method does
nothing.
|
|
removeActionListener |
void removeActionListener(ActionListener l)
Removes the specified action listener so it no longer receives
action events from this menu item.
|
|
removeAll |
void removeAll()
Removes all items from this menu.
public void removeAll()
-
Removes all items from this menu.
- Since:
- JDK1.0.
|
|
removeNotify |
void removeNotify()
Removes the menu's peer.
public void removeNotify()
-
Removes the menu's peer. The peer allows us to modify the appearance
of the menu without changing its functionality.
- Overrides:
removeNotify in class MenuComponent
|
|
setActionCommand |
void setActionCommand(java.lang.String command)
Sets the command name of the action event that is fired
by this menu item.
public void setActionCommand(java.lang.String command)
-
Sets the command name of the action event that is fired
by this menu item.
By default, the action command is set to the label of
the menu item.
- Parameters:
command - the action command to be set
for this menu item.- Since:
- JDK1.1
- See Also:
MenuItem.getActionCommand()
|
|
setEnabled |
void setEnabled(boolean b)
Sets whether or not this menu item can be chosen.
public void setEnabled(boolean b)
-
Sets whether or not this menu item can be chosen.
- Parameters:
b - if true , enables this menu item;
if false , disables it.- Since:
- JDK1.1
- See Also:
MenuItem.isEnabled()
|
|
setFont |
void setFont(Font f)
Sets the font to be used for this menu component to the specified
font.
public void setFont( Font f)
-
Sets the font to be used for this menu component to the specified
font. This font is also used by all subcomponents of this menu
component, unless those subcomponents specify a different font.
Some platforms may not support setting of all font attributes
of a menu component; in such cases, calling setFont
will have no effect on the unsupported font attributes of this
menu component. Unless subcomponents of this menu component
specify a different font, this font will be used by those
subcomponents if supported by the underlying platform.
- Parameters:
f - the font to be set- See Also:
MenuComponent.getFont() ,
Font.getAttributes() ,
TextAttribute
|
|
setLabel |
void setLabel(java.lang.String label)
Sets the label for this menu item to the specified label.
public void setLabel(java.lang.String label)
-
Sets the label for this menu item to the specified label.
- Parameters:
label - the new label, or null for no label.- Since:
- JDK1.0
- See Also:
MenuItem.getLabel()
|
|
setName |
void setName(java.lang.String name)
Sets the name of the component to the specified string.
public void setName(java.lang.String name)
-
Sets the name of the component to the specified string.
- Parameters:
name - the name of the menu component- Since:
- JDK1.1
- See Also:
MenuComponent.getName()
|
|
setShortcut |
void setShortcut(MenuShortcut s)
Set the MenuShortcut object associated with this
menu item.
-
Set the MenuShortcut object associated with this
menu item. If a menu shortcut is already associated with
this menu item, it is replaced.
- Parameters:
s - the menu shortcut to associate
with this menu item.- Since:
- JDK1.1
- See Also:
MenuItem.getShortcut()
|
|
toString |
java.lang.String toString()
Returns a representation of this menu component as a string.
public java.lang.String toString()
-
Returns a representation of this menu component as a string.
- Overrides:
toString in class java.lang.Object
- Returns:
- a string representation of this menu component
|