Java javax.swing JMenu fields, constructors, methods, implement or subclass

Example usage for Java javax.swing JMenu fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for javax.swing JMenu.

The text is from its open source code.

Subclass

javax.swing.JMenu has subclasses.
Click this link to see all its subclasses.

Constructor

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.

Method

JMenuItemadd(JMenuItem menuItem)
Appends a menu item to the end of this menu.
Componentadd(Component c)
Appends a component to the end of this menu.
JMenuItemadd(String s)
Creates a new menu item with the specified text and appends it to the end of this menu.
JMenuItemadd(Action a)
Creates a new menu item attached to the specified Action object and appends it to the end of this menu.
Componentadd(Component c, int index)
Adds the specified component to this container at the given position.
voidaddActionListener(ActionListener l)
Adds an ActionListener to the button.
voidaddChangeListener(ChangeListener l)
Adds a ChangeListener to the button.
voidaddComponentListener(ComponentListener l)
Adds the specified component listener to receive component events from this component.
voidaddMenuKeyListener(MenuKeyListener l)
Adds a MenuKeyListener to the menu item.
voidaddMenuListener(MenuListener l)
Adds a listener for menu events.
voidaddMouseListener(MouseListener l)
Adds the specified mouse listener to receive mouse events from this component.
voidaddSeparator()
Appends a new separator to the end of the menu.
voidapplyComponentOrientation(ComponentOrientation o)
Sets the ComponentOrientation property of this menu and all components contained within it.
voiddoClick(int pressTime)
Programmatically performs a "click".
voiddoClick()
Programmatically perform a "click".
KeyStrokegetAccelerator()
Returns the KeyStroke which serves as an accelerator for the menu item.
AccessibleContextgetAccessibleContext()
Gets the AccessibleContext associated with this JMenu.
ActiongetAction()
Returns the currently set Action for this ActionEvent source, or null if no Action is set.
StringgetActionCommand()
Returns the action command for this button.
ActionListener[]getActionListeners()
Returns an array of all the ActionListeners added to this AbstractButton with addActionListener().
ComponentgetComponent()
Returns the java.awt.Component used to paint this MenuElement.
ComponentgetComponent(int n)
Gets the nth component in this container.
intgetComponentCount()
Gets the number of components in this panel.
Component[]getComponents()
Gets all the components in this container.
intgetDelay()
Returns the suggested delay, in milliseconds, before submenus are popped up or down.
FontgetFont()
Gets the font of this component.
JMenuItemgetItem(int pos)
Returns the JMenuItem at the specified position.
intgetItemCount()
Returns the number of items on the menu, including separators.
ComponentgetMenuComponent(int n)
Returns the component at position n.
intgetMenuComponentCount()
Returns the number of components on the menu.
Component[]getMenuComponents()
Returns an array of Components of the menu's subcomponents.
MenuKeyListener[]getMenuKeyListeners()
Returns an array of all the MenuKeyListeners added to this JMenuItem with addMenuKeyListener().
MenuListener[]getMenuListeners()
Returns an array of all the MenuListeners added to this JMenu with addMenuListener().
StringgetName()
Gets the name of the component.
JPopupMenugetPopupMenu()
Returns the popupmenu associated with this menu.
MenuElement[]getSubElements()
Returns an array of MenuElements containing the submenu for this menu component.
StringgetText()
Returns the button's text.
StringgetToolTipText()
Returns the tooltip string that has been set with setToolTipText.
StringgetUIClassID()
Returns the name of the L&F class that renders this component.
voidinsert(String s, int pos)
Inserts a new menu item with the specified text at a given position.
JMenuIteminsert(JMenuItem mi, int pos)
Inserts the specified JMenuitem at a given position.
JMenuIteminsert(Action a, int pos)
Inserts a new menu item attached to the specified Action object at a given position.
voidinsertSeparator(int index)
Inserts a separator at the specified position.
booleanisEnabled()
Determines whether this component is enabled.
booleanisMenuComponent(Component c)
Returns true if the specified component exists in the submenu hierarchy.
booleanisPopupMenuVisible()
Returns true if the menu's popup window is visible.
booleanisSelected()
Returns true if the menu is currently selected (highlighted).
booleanisTearOff()
Returns true if the menu can be torn off.
booleanisTopLevelMenu()
Returns true if the menu is a 'top-level menu', that is, if it is the direct child of a menubar.
booleanisVisible()
Determines whether this component should be visible when its parent is visible.
voidmenuSelectionChanged(boolean isIncluded)
Messaged when the menubar selection changes to activate or deactivate this menu.
voidputClientProperty(Object key, Object value)
Adds an arbitrary key/value "client property" to this component.
voidremove(JMenuItem item)
Removes the specified menu item from this menu.
voidremove(int pos)
Removes the menu item at the specified index from this menu.
voidremove(Component c)
Removes the component c from this menu.
voidremoveAll()
Removes all menu items from this menu.
voidremoveMenuListener(MenuListener l)
Removes a listener for menu events.
voidrequestFocus()
Requests that this Component gets the input focus.
voidrevalidate()
Supports deferred automatic layout.
voidsetAccelerator(KeyStroke keyStroke)
setAccelerator is not defined for JMenu.
voidsetAction(Action a)
Sets the Action.
voidsetActionCommand(String actionCommand)
Sets the action command for this button.
voidsetBackground(Color bg)
Sets the background color of this component.
voidsetComponentOrientation(ComponentOrientation o)
voidsetDelay(int d)
Sets the suggested delay before the menu's PopupMenu is popped up or down.
voidsetEnabled(boolean b)
Enables or disables the menu item.
voidsetFont(Font font)
Sets the font for this component.
voidsetForeground(Color fg)
Sets the foreground color of this component.
voidsetHorizontalTextPosition(int textPosition)
Sets the horizontal position of the text relative to the icon.
voidsetIcon(Icon defaultIcon)
Sets the button's default icon.
voidsetMargin(Insets m)
Sets space for margin between the button's border and the label.
voidsetMaximumSize(Dimension maximumSize)
Sets the maximum size of this component to a constant value.
voidsetMenuLocation(int x, int y)
Sets the location of the popup component.
voidsetMnemonic(int mnemonic)
Sets the keyboard mnemonic on the current model.
voidsetModel(ButtonModel newModel)
Sets the data model for the "menu button" -- the label that the user clicks to open or close the menu.
voidsetName(String name)
Sets the name of the component to the specified string.
voidsetPopupMenuVisible(boolean b)
Sets the visibility of the menu's popup.
voidsetPreferredSize(Dimension preferredSize)
Sets the preferred size of this component.
voidsetSelected(boolean b)
Sets the selection status of the menu.
voidsetText(String text)
Sets the button's text.
voidsetToolTipText(String text)
Registers the text to display in a tool tip.
voidsetVisible(boolean aFlag)
Makes the component visible or invisible.
voidvalidate()
Validates this container and all of its subcomponents.