BasicCheckBoxMenuItemUI
, BasicMenuUI
, BasicRadioButtonMenuItemUI
, SynthMenuItemUI
public class BasicMenuItemUI extends MenuItemUI
Modifier and Type | Class | Description |
---|---|---|
protected class |
BasicMenuItemUI.MouseInputHandler |
Deprecated, for removal: This API element is subject to removal in a future version. |
Modifier and Type | Field | Description |
---|---|---|
protected String |
acceleratorDelimiter |
Accelerator delimiter string, such as '+' in 'Ctrl+C' . |
protected Font |
acceleratorFont |
The accelerator font. |
protected Color |
acceleratorForeground |
The color of the accelerator foreground. |
protected Color |
acceleratorSelectionForeground |
The color of the accelerator selection. |
protected Icon |
arrowIcon |
The arrow icon. |
protected Icon |
checkIcon |
The check icon. |
protected int |
defaultTextIconGap |
The gap between the text and the icon. |
protected Color |
disabledForeground |
The color of the disabled foreground. |
protected MenuDragMouseListener |
menuDragMouseListener |
The instance of MenuDragMouseListener . |
protected JMenuItem |
menuItem |
The instance of JMenuItem . |
protected MenuKeyListener |
menuKeyListener |
The instance of MenuKeyListener . |
protected MouseInputListener |
mouseInputListener |
The instance of MouseInputListener . |
protected boolean |
oldBorderPainted |
The value represents if the old border is painted. |
protected PropertyChangeListener |
propertyChangeListener |
PropertyChangeListener returned from createPropertyChangeListener . |
protected Color |
selectionBackground |
The color of the selection background. |
protected Color |
selectionForeground |
The color of the selection foreground. |
Constructor | Description |
---|---|
BasicMenuItemUI() |
Constructs a BasicMenuItemUI . |
Modifier and Type | Method | Description |
---|---|---|
protected MenuDragMouseListener |
createMenuDragMouseListener |
Returns an instance of MenuDragMouseListener . |
protected MenuKeyListener |
createMenuKeyListener |
Returns an instance of MenuKeyListener . |
protected MouseInputListener |
createMouseInputListener |
Returns an instance of MouseInputListener . |
protected PropertyChangeListener |
createPropertyChangeListener |
Creates a PropertyChangeListener which will be added to the menu item. |
static ComponentUI |
createUI |
Returns a new instance of BasicMenuItemUI . |
protected void |
doClick |
Call this method when a menu item is to be activated. |
MenuElement[] |
getPath() |
Returns a menu element path. |
protected Dimension |
getPreferredMenuItemSize |
Returns the preferred size of a menu item. |
protected String |
getPropertyPrefix() |
Returns a property prefix. |
protected void |
installComponents |
Registers the subcomponents of the menu. |
protected void |
installDefaults() |
Installs default properties. |
protected void |
installKeyboardActions() |
Registers keyboard action. |
protected void |
installListeners() |
Registers listeners. |
protected void |
paintBackground |
Draws the background of the menu item. |
protected void |
paintMenuItem |
Paints a menu item. |
protected void |
paintText |
Renders the text of the current menu item. |
protected void |
uninstallComponents |
Unregisters components. |
protected void |
uninstallDefaults() |
Uninstalls default properties. |
protected void |
uninstallKeyboardActions() |
Unregisters keyboard actions. |
protected void |
uninstallListeners() |
Unregisters listeners. |
void |
update |
We draw the background in paintMenuItem() so override update (which fills the background of opaque components by default) to just call paint(). |
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, installUI, paint, uninstallUI
protected Color selectionBackground
protected Color selectionForeground
protected Color disabledForeground
protected Color acceleratorForeground
protected Color acceleratorSelectionForeground
protected String acceleratorDelimiter
'+'
in 'Ctrl+C'
.protected int defaultTextIconGap
protected Font acceleratorFont
protected MouseInputListener mouseInputListener
MouseInputListener
.protected PropertyChangeListener propertyChangeListener
PropertyChangeListener
returned from createPropertyChangeListener
. You should not need to access this field, rather if you want to customize the PropertyChangeListener
override createPropertyChangeListener
.protected Icon arrowIcon
protected Icon checkIcon
protected boolean oldBorderPainted
public BasicMenuItemUI()
BasicMenuItemUI
.public static ComponentUI createUI(JComponent c)
BasicMenuItemUI
.c
- a componentBasicMenuItemUI
protected void installDefaults()
protected void installComponents(JMenuItem menuItem)
menuItem
- a menu itemprotected String getPropertyPrefix()
protected void installListeners()
protected void installKeyboardActions()
protected void uninstallDefaults()
protected void uninstallComponents(JMenuItem menuItem)
menuItem
- a menu itemprotected void uninstallListeners()
protected void uninstallKeyboardActions()
protected MouseInputListener createMouseInputListener(JComponent c)
MouseInputListener
.c
- a componentMouseInputListener
protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
MenuDragMouseListener
.c
- a componentMenuDragMouseListener
protected MenuKeyListener createMenuKeyListener(JComponent c)
MenuKeyListener
.c
- a componentMenuKeyListener
protected PropertyChangeListener createPropertyChangeListener(JComponent c)
PropertyChangeListener
which will be added to the menu item. If this method returns null then it will not be added to the menu item.c
- a componentPropertyChangeListener
or nullprotected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap)
c
- a componentcheckIcon
- a check iconarrowIcon
- an arrow icondefaultTextIconGap
- a gap between a text and an iconpublic void update(Graphics g, JComponent c)
update
in class ComponentUI
g
- the Graphics
context in which to paintc
- the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsprotected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap)
g
- an instance of Graphics
c
- a componentcheckIcon
- a check iconarrowIcon
- an arrow iconbackground
- a background colorforeground
- a foreground colordefaultTextIconGap
- a gap between a text and an iconprotected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
g
- the paint graphicsmenuItem
- menu item to be paintedbgColor
- selection background colorprotected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text)
g
- graphics contextmenuItem
- menu item to rendertextRect
- bounding rectangle for rendering the texttext
- string to renderpublic MenuElement[] getPath()
protected void doClick(MenuSelectionManager msm)
msm
- A MenuSelectionManager. The visual feedback and internal bookkeeping tasks are delegated to this MenuSelectionManager. If null
is passed as this argument, the MenuSelectionManager.defaultManager
is used.
© 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/plaf/basic/BasicMenuItemUI.html