java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JMenuItem
javax.swing.JMenu
public class JMenu extends JMenuItem
Constructor Summary |
---|
JMenu()
Constructs a new JMenu with no
text. |
JMenu(String s)
Constructs a new JMenu with the supplied string
as its text. |
JMenu(String s,
boolean b)
Constructs 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 menu item to the end of this menu. |
JMenuItem |
add(String s)
Creates a new menu item with the specified text and appends it to the end of this menu. |
int |
getDelay()
Returns the suggested delay, in milliseconds, before submenus are popped up or down. |
JMenuItem |
getItem(int pos)
Returns the JMenuItem at the specified position. |
int |
getItemCount()
Returns the number of items on the menu, including separators. |
Component |
getMenuComponent(int n)
Returns the component at position n . |
int |
getMenuComponentCount()
Returns the number of components on the menu. |
Component[] |
getMenuComponents()
Returns an array of Component s of the menu's
subcomponents. |
JMenuItem |
insert(JMenuItem mi,
int pos)
Inserts the specified JMenuitem at a given position. |
void |
insert(String s,
int pos)
Inserts a new menu item with the specified text at a given position. |
void |
insertSeparator(int index)
Inserts a separator at the specified position. |
boolean |
isMenuComponent(Component c)
Returns true if the specified component exists in the submenu hierarchy. |
boolean |
isSelected()
Returns true if the menu is currently selected (highlighted). |
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 |
remove(Component c)
Removes the component c from this menu. |
void |
remove(int pos)
Removes the menu item at the specified index from this menu. |
void |
remove(JMenuItem item)
Removes the specified menu item from this menu. |
void |
removeAll()
Removes all menu items from this menu. |
void |
setDelay(int d)
Sets the suggested delay before the menu's PopupMenu
is popped up or down. |
void |
setSelected(boolean b)
Sets the selection status of the menu. |