Example usage for Java javax.swing JMenu fields, constructors, methods, implement or subclass
The text is from its open source code.
JMenu(String s) Constructs a new JMenu with the supplied string as its text. | |
JMenu(Action a) Constructs a menu whose properties are taken from the Action supplied. | |
JMenu() Constructs a new JMenu with no 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. |
JMenuItem | add(JMenuItem menuItem) Appends a menu item to the end of this menu. |
Component | add(Component c) Appends a component 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. |
JMenuItem | add(Action a) Creates a new menu item attached to the specified Action object and appends it to the end of this menu. |
Component | add(Component c, int index) Adds the specified component to this container at the given position. |
void | addActionListener(ActionListener l) Adds an ActionListener to the button. |
void | addChangeListener(ChangeListener l) Adds a ChangeListener to the button. |
void | addComponentListener(ComponentListener l) Adds the specified component listener to receive component events from this component. |
void | addMenuKeyListener(MenuKeyListener l) Adds a MenuKeyListener to the menu item. |
void | addMenuListener(MenuListener l) Adds a listener for menu events. |
void | addMouseListener(MouseListener l) Adds the specified mouse listener to receive mouse events from this component. |
void | addSeparator() Appends a new separator to the end of the menu. |
void | applyComponentOrientation(ComponentOrientation o) Sets the ComponentOrientation property of this menu and all components contained within it. |
void | doClick(int pressTime) Programmatically performs a "click". |
void | doClick() Programmatically perform a "click". |
KeyStroke | getAccelerator() Returns the KeyStroke which serves as an accelerator for the menu item. |
AccessibleContext | getAccessibleContext() Gets the AccessibleContext associated with this JMenu. |
Action | getAction() Returns the currently set Action for this ActionEvent source, or null if no Action is set. |
String | getActionCommand() Returns the action command for this button. |
ActionListener[] | getActionListeners() Returns an array of all the ActionListener s added to this AbstractButton with addActionListener(). |
Component | getComponent() Returns the java.awt.Component used to paint this MenuElement . |
Component | getComponent(int n) Gets the nth component in this container. |
int | getComponentCount() Gets the number of components in this panel. |
Component[] | getComponents() Gets all the components in this container. |
int | getDelay() Returns the suggested delay, in milliseconds, before submenus are popped up or down. |
Font | getFont() Gets the font of this component. |
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. |
MenuKeyListener[] | getMenuKeyListeners() Returns an array of all the MenuKeyListener s added to this JMenuItem with addMenuKeyListener(). |
MenuListener[] | getMenuListeners() Returns an array of all the MenuListener s added to this JMenu with addMenuListener(). |
String | getName() Gets the name of the component. |
JPopupMenu | getPopupMenu() Returns the popupmenu associated with this menu. |
MenuElement[] | getSubElements() Returns an array of MenuElement s containing the submenu for this menu component. |
String | getText() Returns the button's text. |
String | getToolTipText() Returns the tooltip string that has been set with setToolTipText . |
String | getUIClassID() Returns the name of the L&F class that renders this component. |
void | insert(String s, int pos) Inserts a new menu item with the specified text at a given position. |
JMenuItem | insert(JMenuItem mi, int pos) Inserts the specified JMenuitem at a given position. |
JMenuItem | insert(Action a, int pos) Inserts a new menu item attached to the specified Action object at a given position. |
void | insertSeparator(int index) Inserts a separator at the specified position. |
boolean | isEnabled() Determines whether this component is enabled. |
boolean | isMenuComponent(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 (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. |
boolean | isVisible() Determines whether this component should be visible when its parent is visible. |
void | menuSelectionChanged(boolean isIncluded) Messaged when the menubar selection changes to activate or deactivate this menu. |
void | putClientProperty(Object key, Object value) Adds an arbitrary key/value "client property" to this component. |
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 | remove(Component c) Removes the component c from this menu. |
void | removeAll() Removes all menu items from this menu. |
void | removeMenuListener(MenuListener l) Removes a listener for menu events. |
void | requestFocus() Requests that this Component gets the input focus. |
void | revalidate() Supports deferred automatic layout. |
void | setAccelerator(KeyStroke keyStroke)setAccelerator is not defined for JMenu . |
void | setAction(Action a) Sets the Action . |
void | setActionCommand(String actionCommand) Sets the action command for this button. |
void | setBackground(Color bg) Sets the background color of this component. |
void | setComponentOrientation(ComponentOrientation o) |
void | setDelay(int d) Sets the suggested delay before the menu's PopupMenu is popped up or down. |
void | setEnabled(boolean b) Enables or disables the menu item. |
void | setFont(Font font) Sets the font for this component. |
void | setForeground(Color fg) Sets the foreground color of this component. |
void | setHorizontalTextPosition(int textPosition) Sets the horizontal position of the text relative to the icon. |
void | setIcon(Icon defaultIcon) Sets the button's default icon. |
void | setMargin(Insets m) Sets space for margin between the button's border and the label. |
void | setMaximumSize(Dimension maximumSize) Sets the maximum size of this component to a constant value. |
void | setMenuLocation(int x, int y) Sets the location of the popup component. |
void | setMnemonic(int mnemonic) Sets the keyboard mnemonic on the current model. |
void | setModel(ButtonModel newModel) Sets the data model for the "menu button" -- the label that the user clicks to open or close the menu. |
void | setName(String name) Sets the name of the component to the specified string. |
void | setPopupMenuVisible(boolean b) Sets the visibility of the menu's popup. |
void | setPreferredSize(Dimension preferredSize) Sets the preferred size of this component. |
void | setSelected(boolean b) Sets the selection status of the menu. |
void | setText(String text) Sets the button's text. |
void | setToolTipText(String text) Registers the text to display in a tool tip. |
void | setVisible(boolean aFlag) Makes the component visible or invisible. |
void | validate() Validates this container and all of its subcomponents. |