ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, MenuElement, SwingConstants
@JavaBean(description="A popup window containing menu items displayed in a menu bar.") public class JMenu extends JMenuItem implements Accessible, MenuElement
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. 
 Menus can be configured, and to some degree controlled, by Actions. Using an Action with a menu has many benefits beyond directly configuring a menu. Refer to  Swing Components Supporting Action for more details, and you can find more information in How to Use Actions, a section in The Java Tutorial. 
For information and examples of using menus see How to Use Menus, a section in The Java Tutorial.
Warning: Swing is not thread safe. For more information see Swing's Threading Policy.
 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 JavaBeans has been added to the java.beans package. Please see XMLEncoder.
| Modifier and Type | Class | Description | 
|---|---|---|
| protected class  | JMenu.AccessibleJMenu | This class implements accessibility support for the  JMenuclass. | 
| protected class  | JMenu.WinListener | A listener class that watches for a popup window closing. | 
JMenuItem.AccessibleJMenuItem
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
| Modifier and Type | Field | Description | 
|---|---|---|
| protected JMenu.WinListener | popupListener | The window-closing listener for the popup. | 
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
| Constructor | Description | 
|---|---|
| JMenu() | Constructs a new  JMenuwith no text. | 
| JMenu | Constructs a new  JMenuwith the supplied string as its text. | 
| JMenu | Constructs a new  JMenuwith the supplied string as its text and specified as a tear-off menu or not. | 
| JMenu | Constructs a menu whose properties are taken from the  Actionsupplied. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| 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 | Creates a new menu item with the specified text and appends it to the end of this menu. | 
| JMenuItem | add | Creates a new menu item attached to the specified  Actionobject and appends it to the end of this menu. | 
| JMenuItem | add | Appends a menu item 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  ComponentOrientationproperty of this menu and all components contained within it. | 
| protected PropertyChangeListener | createActionChangeListener | Returns a properly configured  PropertyChangeListenerwhich updates the control as changes to theActionoccur. | 
| protected JMenuItem | createActionComponent | Factory method which creates the  JMenuItemforActions added to theJMenu. | 
| 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.Componentused to paint thisMenuElement. | 
| int | getDelay() | Returns the suggested delay, in milliseconds, before submenus are popped up or down. | 
| JMenuItem | getItem | Returns the  JMenuItemat 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[] | getSubElements() | Returns an array of  MenuElements containing the submenu for this menu component. | 
| String | getUIClassID() | Returns the name of the L&F class that renders this component. | 
| void | insert | Inserts a new menu item with the specified text at a given position. | 
| JMenuItem | insert | Inserts a new menu item attached to the specified  Actionobject at a given position. | 
| JMenuItem | insert | Inserts the specified  JMenuitemat a given position. | 
| void | insertSeparator | Inserts a separator at the specified position. | 
| boolean | isMenuComponent | 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. | 
| void | menuSelectionChanged | Messaged when the menubar selection changes to activate or deactivate this menu. | 
| protected String | paramString() | Returns a string representation of this  JMenu. | 
| protected void | processKeyEvent | Processes key stroke events such as mnemonics and accelerators. | 
| void | remove | Removes the menu item at the specified index from this menu. | 
| void | remove | Removes the component  cfrom this menu. | 
| void | remove | Removes the specified menu item from this menu. | 
| void | removeAll() | Removes all menu items from this menu. | 
| void | removeMenuListener | Removes a listener for menu events. | 
| void | setAccelerator | setAcceleratoris not defined forJMenu. | 
| void | setComponentOrientation | Sets the orientation for this menu and its associated popup menu determined by the  ComponentOrientationargument. | 
| void | setDelay | Sets the suggested delay before the menu's  PopupMenuis popped up or down. | 
| void | setMenuLocation | Sets the location of the popup component. | 
| void | setModel | Sets the data model for the "menu button" -- the label that the user clicks to open or close the menu. | 
| void | setPopupMenuVisible | Sets the visibility of the menu's popup. | 
| void | setSelected | Sets the selection status of the menu. | 
| void | updateUI() | Resets the UI property with a value from the current look and feel. | 
actionPropertyChanged, addMenuDragMouseListener, addMenuKeyListener, configurePropertiesFromAction, fireMenuDragMouseDragged, fireMenuDragMouseEntered, fireMenuDragMouseExited, fireMenuDragMouseReleased, fireMenuKeyPressed, fireMenuKeyReleased, fireMenuKeyTyped, getAccelerator, getMenuDragMouseListeners, getMenuKeyListeners, init, isArmed, processKeyEvent, processMenuDragMouseEvent, processMenuKeyEvent, processMouseEvent, removeMenuDragMouseListener, removeMenuKeyListener, setArmed, setEnabled, setUI
addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, paintBorder, removeActionListener, removeChangeListener, removeItemListener, removeNotify, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
processKeyEvent, processMouseEvent
protected JMenu.WinListener popupListener
public JMenu()
JMenu with no text.public JMenu(String s)
JMenu with the supplied string as its text.s - the text for the menu labelpublic JMenu(Action a)
Action supplied.a - an Action
public JMenu(String s, boolean b)
JMenu with the supplied string as its text and specified as a tear-off menu or not.s - the text for the menu labelb - can the menu be torn off (not yet implemented)public void updateUI()
@BeanProperty(bound=false) public String getUIClassID()
getUIClassID in class JMenuItem
public void setModel(ButtonModel newModel)
setModel in class AbstractButton
newModel - the ButtonModel
public boolean isSelected()
isSelected in class AbstractButton
@BeanProperty(expert=true, hidden=true, description="When the menu is selected, its popup child is shown.") public void setSelected(boolean b)
setSelected in class AbstractButton
b - true to select (highlight) the menu; false to de-select the menupublic boolean isPopupMenuVisible()
@BeanProperty(bound=false, expert=true, hidden=true, description="The popup menu\'s visibility") public void setPopupMenuVisible(boolean b)
b - a boolean value -- true to make the menu visible, false to hide itprotected Point getPopupMenuOrigin()
JMenu's popup menu. This method uses Look and Feel properties named Menu.menuPopupOffsetX, Menu.menuPopupOffsetY, Menu.submenuPopupOffsetX, and Menu.submenuPopupOffsetY to adjust the exact location of popup.Point in the coordinate space of the menu which should be used as the origin of the JMenu's popup menupublic int getDelay()
delay property. In most cases, the delay is not observed for top level menus or while dragging. The default for delay is 0. This method is a property of the look and feel code and is used to manage the idiosyncrasies of the various UI implementations.delay property@BeanProperty(bound=false, expert=true, description="The delay between menu selection and making the popup menu visible") public void setDelay(int d)
PopupMenu is popped up or down. Each look and feel (L&F) may determine it's own policy for observing the delay property. In most cases, the delay is not observed for top level menus or while dragging. This method is a property of the look and feel code and is used to manage the idiosyncrasies of the various UI implementations.d - the number of milliseconds to delayIllegalArgumentException - if d is less than 0public void setMenuLocation(int x, int y)
x - the x coordinate of the popup's new positiony - the y coordinate of the popup's new positionpublic JMenuItem add(JMenuItem menuItem)
menuItem - the JMenuitem to be addedJMenuItem addedpublic Component add(Component c)
public Component add(Component c, int index)
index equals -1, the component will be appended to the end.public JMenuItem add(String s)
s - the string for the menu item to be addedJMenuItem
public JMenuItem add(Action a)
Action object and appends it to the end of this menu.a - the Action for the menu item to be addedJMenuItem
protected JMenuItem createActionComponent(Action a)
JMenuItem for Actions added to the JMenu.a - the Action for the menu item to be addedprotected PropertyChangeListener createActionChangeListener(JMenuItem b)
PropertyChangeListener which updates the control as changes to the Action occur.b - a menu item for which to create a PropertyChangeListener
PropertyChangeListener for b
public void addSeparator()
public void insert(String s, int pos)
s - the text for the menu item to addpos - an integer specifying the position at which to add the new menu itemIllegalArgumentException - when the value of pos < 0public JMenuItem insert(JMenuItem mi, int pos)
JMenuitem at a given position.mi - the JMenuitem to addpos - an integer specifying the position at which to add the new JMenuitem
IllegalArgumentException - if the value of pos < 0public JMenuItem insert(Action a, int pos)
Action object at a given position.a - the Action object for the menu item to addpos - an integer specifying the position at which to add the new menu itemIllegalArgumentException - if the value of pos < 0public void insertSeparator(int index)
index - an integer specifying the position at which to insert the menu separatorIllegalArgumentException - if the value of index < 0public JMenuItem getItem(int pos)
JMenuItem at the specified position. If the component at pos is not a menu item, null is returned. This method is included for AWT compatibility.pos - an integer specifying the positionnull if the item as the specified position is not a menu itemIllegalArgumentException - if the value of pos < 0@BeanProperty(bound=false) public int getItemCount()
@BeanProperty(bound=false) public boolean isTearOff()
Error - if invoked -- this method is not yet implementedpublic void remove(JMenuItem item)
item - the JMenuItem to be removed from the menupublic void remove(int pos)
remove in class Container
pos - the position of the item to be removedIllegalArgumentException - if the value of pos < 0, or if pos is greater than the number of menu itemspublic void remove(Component c)
c from this menu.public void removeAll()
@BeanProperty(bound=false) public int getMenuComponentCount()
public Component getMenuComponent(int n)
n.n - the position of the component to be returnednull if there is no popup menu@BeanProperty(bound=false) public Component[] getMenuComponents()
Components of the menu's subcomponents. Note that this returns all Components in the popup menu, including separators.Components or an empty array if there is no popup menu@BeanProperty(bound=false) public boolean isTopLevelMenu()
public boolean isMenuComponent(Component c)
c - the Component to be testedComponent exists, false otherwise@BeanProperty(bound=false) public JPopupMenu getPopupMenu()
JPopupMenu associated with this menupublic void addMenuListener(MenuListener l)
l - the listener to be addedpublic void removeMenuListener(MenuListener l)
l - the listener to be removed@BeanProperty(bound=false) public MenuListener[] getMenuListeners()
MenuListeners added to this JMenu with addMenuListener().MenuListeners added or an empty array if no listeners have been addedprotected void fireMenuSelected()
Error - if there is a null listenerprotected void fireMenuDeselected()
Error - if there is a null listenerprotected void fireMenuCanceled()
Error - if there is a null listenerprotected JMenu.WinListener createWinListener(JPopupMenu p)
p - the JPopupMenu
@BeanProperty(bound=false) public MenuElement[] getSubElements()
MenuElements containing the submenu for this menu component. If popup menu is null returns an empty array. This method is required to conform to the MenuElement interface. Note that since JSeparators do not conform to the MenuElement interface, this array will only contain JMenuItems.getSubElements in interface MenuElement
getSubElements in class JMenuItem
MenuElement objectspublic Component getComponent()
java.awt.Component used to paint this MenuElement. The returned component is used to convert events and detect if an event is inside a menu component.getComponent in interface MenuElement
getComponent in class JMenuItem
Component that paints this menu itempublic void applyComponentOrientation(ComponentOrientation o)
ComponentOrientation property of this menu and all components contained within it. This includes all components returned by getMenuComponents.applyComponentOrientation in class Container
o - the new component orientation of this menu and the components contained within it.NullPointerException - if orientation is null.public void setComponentOrientation(ComponentOrientation o)
ComponentOrientation argument.setComponentOrientation in class Component
o - the new orientation for this menu and its associated popup menu.public void setAccelerator(KeyStroke keyStroke)
setAccelerator is not defined for JMenu. Use setMnemonic instead.setAccelerator in class JMenuItem
keyStroke - the keystroke combination which will invoke the JMenuItem's actionlisteners without navigating the menu hierarchyError - if invoked -- this method is not defined for JMenu. Use setMnemonic insteadprotected void processKeyEvent(KeyEvent evt)
processKeyEvent in class JComponent
evt - the key event to be processedpublic void doClick(int pressTime)
AbstractButton.doClick in order to make the menu pop up.doClick in class AbstractButton
pressTime - indicates the number of milliseconds the button was pressed forprotected String paramString()
JMenu. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.paramString in class JMenuItem
@BeanProperty(bound=false) public AccessibleContext getAccessibleContext()
getAccessibleContext in interface Accessible
getAccessibleContext in class JMenuItem
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/JMenu.html