|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.awt.Component
![]()
![]()
![]()
java.awt.Container
![]()
![]()
![]()
javax.swing.JComponent
![]()
![]()
![]()
javax.swing.AbstractButton
![]()
![]()
![]()
javax.swing.JMenuItem
![]()
![]()
![]()
javax.swing.JMenu
, ItemSelectable
, MenuContainer
, Serializable
, Accessible
, MenuElement
, SwingConstants

public class JMenu

, MenuElement

An implementation of a menu -- a popup window containing
JMenuItems that
is displayed when the user selects an item on the JMenuBar.
In addition to JMenuItems, a JMenu can
also contain JSeparators.
In essence, a menu is a button with an associated JPopupMenu.
When the "button" is pressed, the JPopupMenu appears. If the
"button" is on the JMenuBar, the menu is a top-level window.
If the "button" is another menu item, then the JPopupMenu is
"pull-right" menu.
For information and examples of using menus see How to Use Menus, a section in The Java Tutorial.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder
.
JMenuItem
,
JSeparator
,
JMenuBar
,
JPopupMenu
,
Serialized Form| Nested Class Summary | |
|---|---|
protected class |
JMenu.AccessibleJMenu
This class implements accessibility support for the JMenu class. |
protected class |
JMenu.WinListener
A listener class that watches for a popup window closing. |
Nested classes/interfaces inherited from class javax.swing.JMenuItem ![]() |
|---|
JMenuItem.AccessibleJMenuItem |
Nested classes/interfaces inherited from class javax.swing.AbstractButton ![]() |
|---|
AbstractButton.AccessibleAbstractButton |
Nested classes/interfaces inherited from class javax.swing.JComponent ![]() |
|---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container ![]() |
|---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component ![]() |
|---|
Component.AccessibleAWTComponent |
| Field Summary | |
|---|---|
protected JMenu.WinListener |
popupListener
The window-closing listener for the popup. |
Fields inherited from class javax.swing.JComponent ![]() |
|---|
accessibleContext |
Fields inherited from class java.awt.Component ![]() |
|---|
BOTTOM_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants ![]() |
|---|
BOTTOM |
Fields inherited from interface java.awt.image.ImageObserver ![]() |
|---|
ABORT |
| Constructor Summary | |
|---|---|
JMenu
Constructs a new JMenu with no text. |
|
JMenu
Constructs a menu whose properties are taken from the Action supplied. |
|
JMenu
Constructs a new JMenu with the supplied string
as its text. |
|
JMenu
Constructs a new JMenu with the supplied string as
its text and specified as a tear-off menu or not. |
|
| Method Summary | |
|---|---|
JMenuItem |
add
Creates a new menu item attached to the specified Action object and appends it to the end of this menu. |
Component |
add
Appends a component to the end of this menu. |
Component |
add
Adds the specified component to this container at the given position. |
JMenuItem |
add
Appends a menu item to the end of this menu. |
JMenuItem |
add
Creates a new menu item with the specified text and appends it to the end of this menu. |
void |
addMenuListener
Adds a listener for menu events. |
void |
addSeparator
Appends a new separator to the end of the menu. |
void |
applyComponentOrientation
Sets the ComponentOrientation property of this menu
and all components contained within it. |
protected void |
configurePropertiesFromAction
Factory method which sets the ActionEvent
source's properties according to values from the
Action instance. |
protected PropertyChangeListener |
createActionChangeListener
Returns a properly configured PropertyChangeListener
which updates the control as changes to the Action occur. |
protected JMenuItem |
createActionComponent
Factory method which creates the JMenuItem for
Actions added to the JMenu. |
protected JMenu.WinListener |
createWinListener
Creates a window-closing listener for the popup. |
void |
doClick
Programmatically performs a "click". |
protected void |
fireMenuCanceled
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireMenuDeselected
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireMenuSelected
Notifies all listeners that have registered interest for notification on this event type. |
AccessibleContext |
getAccessibleContext
Gets the AccessibleContext associated with this JMenu. |
Component |
getComponent
Returns the java.awt.Component used to
paint this MenuElement. |
int |
getDelay
Returns the suggested delay, in milliseconds, before submenus are popped up or down. |
JMenuItem |
getItem
Returns the JMenuItem at the specified position. |
int |
getItemCount
Returns the number of items on the menu, including separators. |
Component |
getMenuComponent
Returns the component at position n. |
int |
getMenuComponentCount
Returns the number of components on the menu. |
Component |
getMenuComponents
Returns an array of Components of the menu's
subcomponents. |
MenuListener |
getMenuListeners
Returns an array of all the MenuListeners added
to this JMenu with addMenuListener(). |
JPopupMenu |
getPopupMenu
Returns the popupmenu associated with this menu. |
protected Point |
getPopupMenuOrigin
Computes the origin for the JMenu's popup menu. |
MenuElement | |