Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--com.sun.java.swing.JComponent | +--com.sun.java.swing.AbstractButton | +--com.sun.java.swing.JMenuItem | +--com.sun.java.swing.JMenu
JMenuItem
s that
is displayed when the user selects an item on the JMenuBar
. In addition
to JMenuItems, a JMenu can also contain JSeparator
s.
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 the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JMenu key assignments.
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 Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.
Inner Class Summary | |
JMenu.AccessibleJMenu
The class used to obtain the accessible role for this object. |
|
JMenu.WinListener
A listener class that watches for a popup window closing. |
Inner classes inherited from class com.sun.java.swing.JMenuItem | |
JMenuItem.AccessibleJMenuItem |
Inner classes inherited from class com.sun.java.swing.AbstractButton | |
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener |
Inner classes inherited from class com.sun.java.swing.JComponent | |
JComponent.AccessibleJComponent |
Field Summary | |
JMenu.WinListener | popupListener
The window-closing listener for the popup. |
Fields inherited from class com.sun.java.swing.JComponent | |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component | |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Constructor Summary | |
JMenu()
Creates a new JMenu with no text. |
|
JMenu(java.lang.String s)
Creates a new JMenu with the supplied string as its text |
|
JMenu(java.lang.String s,
boolean b)
Creates a new JMenu with the supplied string as its text and specified as a tear-off menu or not. |
Method Summary | |
JMenuItem | add(JMenuItem menuItem)
Appends a menuitem to the end of this menu. |
java.awt.Component | add(java.awt.Component c)
Appends a component to the end of this menu. |
void | add(java.lang.String s)
Creates a new menuitem with the specified text and appends it to the end of this menu. |
JMenuItem | add(Action a)
Creates a new menuitem attached to the specified Action object and appends it to the end of this menu. |
void | addMenuListener(MenuListener l)
Add a listener for menu events |
void | addSeparator()
Append a new separator to the end of the menu. |
java.beans.PropertyChangeListener | createActionChangeListener(JMenuItem b)
|
JMenu.WinListener | createWinListener(JPopupMenu p)
Create a window-closing listener for the popup. |
void | fireMenuDeselected()
Notify all listeners that have registered interest for notification on this event type. |
void | fireMenuSelected()
Notify all listeners that have registered interest for notification on this event type. |
AccessibleContext | getAccessibleContext()
Get the AccessibleContext associated with this JComponent |
java.awt.Component | getComponent()
|
int | getDelay()
Returns the suggested delay before the menu's PopupMenu is popped up or down. |
int | getItemCount()
Returns the number of items on the menu, including separators. |
JMenuItem | getItem(int pos)
Returns the JMenuItem at the specified position. |
int | getMenuComponentCount()
Returns the number of components on the menu. |
java.awt.Component | getMenuComponent(int n)
Returns the component at position n |
java.awt.Component[] | getMenuComponents()
Returns an array of the menu's subcomponents |
JPopupMenu | getPopupMenu()
Returns the popupmenu associated with this menu |
MenuElement[] | getSubElements()
This method should return an array containing the sub-menu components for this menu component |
java.lang.String | getUIClassID()
Returns the name of the L&F class that renders this component. |
void | insert(java.lang.String s,
int pos)
Insert a new menuitem with the specified text at a given position. |
JMenuItem | insert(JMenuItem mi,
int pos)
Insert the specified JMenuitem at a given position. |
JMenuItem | insert(Action a,
int pos)
Insert a new menuitem attached to the specified Action object at a given position. |
void | insertSeparator(int index)
Inserts a separator at the specified position. |
boolean | isMenuComponent(java.awt.Component c)
Returns true if the specified component exists in the submenu hierarchy. |
boolean | isPopupMenuVisible()
Returns true if the menu's popup window is visible. |
boolean | isSelected()
Returns true if the menu is currently selected (popped up). |
boolean | isTearOff()
Returns true if the menu can be torn off. |
boolean | isTopLevelMenu()
Returns true if the menu is a 'top-level menu', that is, if it is the direct child of a menubar. |
void | menuSelectionChanged(boolean isIncluded)
|
java.lang.String | paramString()
Gets the parameter string representing the state of this menu. |
void | processKeyEvent(java.awt.event.KeyEvent e,
MenuElement[] path,
MenuSelectionManager manager)
Implemented to be a MenuElement. |
void | processKeyEvent(java.awt.event.KeyEvent e)
|
void | processMouseEvent(java.awt.event.MouseEvent event,
MenuElement[] path,
MenuSelectionManager manager)
Process a mouse event. event is a MouseEvent with source being the receiving component. componentPath is the path of the receiving MenuComponent in the menu hierarchy. manager is the MenuSelectionManager for the menu hierarchy. |
void | removeAll()
Remove all menu items from this menu. |
void | remove(JMenuItem item)
Removes the specified menu item from this menu. |
void | remove(int pos)
Removes the menu item at the specified index from this menu. |
void | removeMenuListener(MenuListener l)
Remove a listener for menu events |
void | setAccelerator(KeyStroke keyStroke)
|
void | setDelay(int d)
Sets the suggested delay before the menu's PopupMenu is popped up or down. |
void | setMenuLocation(int x,
int y)
Set the location of the popup component |
void | setModel(ButtonModel newModel)
Set the data model for the "menu button" -- the label that the user clicks to open or close the menu. |
void | setPopupMenuVisible(boolean b)
Set the visibility of the Menu's popup portion. |
void | setSelected(boolean b)
Sets the selection status of the menu. |
void | setUI(com.sun.java.swing.plaf.MenuUI ui)
Sets the L&F object that renders this component. |
void | updateUI()
Notification from the UIFactory that the L&F has changed. |
Methods inherited from class com.sun.java.swing.JMenuItem | |
getAccelerator, getAccessibleContext, getComponent, getSubElements, getUIClassID, init, isArmed, menuSelectionChanged, processKeyEvent, processMouseEvent, setAccelerator, setArmed, setEnabled, setUI, updateUI |
Methods inherited from class java.awt.Container | |
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponentAt, getComponentAt, getComponent, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paint, paramString, preferredSize, printComponents, print, processContainerEvent, processEvent, removeAll, remove, remove, removeContainerListener, removeNotify, setLayout, update, validate, validateTree |
Methods inherited from class java.awt.Component | |
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Field Detail |
protected JMenu.WinListener popupListener
Constructor Detail |
public JMenu()
public JMenu(java.lang.String s)
s
- The text for the menu labelpublic JMenu(java.lang.String s, boolean b)
s
- The text for the menu label
b
- can the menu be torn off (not yet implemented)Method Detail |
public void setUI(com.sun.java.swing.plaf.MenuUI ui)
ui
- the new MenuUIpublic void updateUI()
public java.lang.String getUIClassID()
public void setModel(ButtonModel newModel)
m
- the ButtonModelpublic boolean isSelected()
public void setSelected(boolean b)
b
- a boolean value -- true to select the menu and
open it, false to unselect the menu and close itpublic boolean isPopupMenuVisible()
public void setPopupMenuVisible(boolean b)
b
- a boolean value -- true to make the menu visible,
false to hide itpublic int getDelay()
public void setDelay(int d)
d
- the number of milliseconds to delayd
is less than 0.public void setMenuLocation(int x, int y)
x
- the x coordinate of the popup's new position
y
- the y coordinate of the popup's new positionpublic JMenuItem add(JMenuItem menuItem)
menuItem
- the JMenuitem to be addedpublic java.awt.Component add(java.awt.Component c)
c
- the Component to addpublic void add(java.lang.String s)
s
- the string for the menuitem to be addedpublic JMenuItem add(Action a)
a
- the Action for the menuitem to be addedprotected java.beans.PropertyChangeListener createActionChangeListener(JMenuItem b)
public void addSeparator()
public void insert(java.lang.String s, int pos)
s
- the text for the menuitem to add
pos
- an int giving the position at which to add the
new menuitempublic JMenuItem insert(JMenuItem mi, int pos)
mi
- the JMenuitem to add
pos
- an int giving the position at which to add the
new JMenuitempublic JMenuItem insert(Action a, int pos)
a
- the Action object for the menuitem to add
pos
- an int giving the position at which to add the
new menuitempublic void insertSeparator(int index)
index
- an int giving the position at which to
insert the menu separatorindex
is less than 0.public JMenuItem getItem(int pos)
pos
- an int giving the positionindex
is less than 0.public int getItemCount()
public boolean isTearOff()
public void remove(JMenuItem item)
item
- the JMenuItem to be removed from the menupublic void remove(int pos)
index
- the position of the item to be removed.index
is less than 0.public void removeAll()
public int getMenuComponentCount()
public java.awt.Component getMenuComponent(int n)
n
- the position of the component to be returnedpublic java.awt.Component[] getMenuComponents()
public java.lang.String paramString()
public boolean isTopLevelMenu()
public boolean isMenuComponent(java.awt.Component c)
c
- the Component to be testedpublic JPopupMenu getPopupMenu()
public void addMenuListener(MenuListener l)
l
- the listener to be addedpublic void removeMenuListener(MenuListener l)
l
- the listener to be removedprotected void fireMenuSelected()
protected void fireMenuDeselected()
protected JMenu.WinListener createWinListener(JPopupMenu p)
p
- the JPopupMenupublic void processMouseEvent(java.awt.event.MouseEvent event, MenuElement[] path, MenuSelectionManager manager)
public void processKeyEvent(java.awt.event.KeyEvent e, MenuElement[] path, MenuSelectionManager manager)
public void menuSelectionChanged(boolean isIncluded)
public MenuElement[] getSubElements()
public java.awt.Component getComponent()
public void setAccelerator(KeyStroke keyStroke)
protected void processKeyEvent(java.awt.event.KeyEvent e)
public AccessibleContext getAccessibleContext()
Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |