public class BasicMenuItemUI extends MenuItemUI
Modifier and Type | Class and Description |
---|---|
protected class |
BasicMenuItemUI.MouseInputHandler |
Modifier and Type | Field and Description |
---|---|
protected String |
acceleratorDelimiter
加速器的分隔符字符串,如
'+' 在
'Ctrl+C' 。
|
protected Font |
acceleratorFont |
protected Color |
acceleratorForeground |
protected Color |
acceleratorSelectionForeground |
protected Icon |
arrowIcon |
protected Icon |
checkIcon |
protected int |
defaultTextIconGap |
protected Color |
disabledForeground |
protected MenuDragMouseListener |
menuDragMouseListener |
protected JMenuItem |
menuItem |
protected MenuKeyListener |
menuKeyListener |
protected MouseInputListener |
mouseInputListener |
protected boolean |
oldBorderPainted |
protected PropertyChangeListener |
propertyChangeListener
PropertyChangeListener 返回
createPropertyChangeListener 。
|
protected Color |
selectionBackground |
protected Color |
selectionForeground |
Constructor and Description |
---|
BasicMenuItemUI() |
Modifier and Type | Method and Description |
---|---|
protected MenuDragMouseListener |
createMenuDragMouseListener(JComponent c) |
protected MenuKeyListener |
createMenuKeyListener(JComponent c) |
protected MouseInputListener |
createMouseInputListener(JComponent c) |
protected PropertyChangeListener |
createPropertyChangeListener(JComponent c)
创建一个
PropertyChangeListener 将被添加到菜单项。
|
static ComponentUI |
createUI(JComponent c) |
protected void |
doClick(MenuSelectionManager msm)
当菜单项被激活时调用此方法。
|
Dimension |
getMaximumSize(JComponent c)
返回指定组件的最大大小适合的外观和感觉。
|
Dimension |
getMinimumSize(JComponent c)
返回指定组件的最小大小适合的外观和感觉。
|
MenuElement[] |
getPath() |
protected Dimension |
getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) |
Dimension |
getPreferredSize(JComponent c)
返回指定组件的首选大小适合的外观和感觉。
|
protected String |
getPropertyPrefix() |
protected void |
installComponents(JMenuItem menuItem) |
protected void |
installDefaults() |
protected void |
installKeyboardActions() |
protected void |
installListeners() |
void |
installUI(JComponent c)
配置指定的组件适当的外观和感觉。
|
void |
paint(Graphics g, JComponent c)
适当地绘制指定的组件的外观和感觉。
|
protected void |
paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
绘制菜单项的背景。
|
protected void |
paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) |
protected void |
paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text)
呈现当前菜单项的文本。
|
protected void |
uninstallComponents(JMenuItem menuItem) |
protected void |
uninstallDefaults() |
protected void |
uninstallKeyboardActions() |
protected void |
uninstallListeners() |
void |
uninstallUI(JComponent c)
逆转形态,完成指定的组件在
installUI 。
|
void |
update(Graphics g, JComponent c)
我们画的背景paintmenuitem()所以重写更新(填补不透明组件默认背景)打电话paint()。
|
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior
protected JMenuItem menuItem
protected Color selectionBackground
protected Color selectionForeground
protected Color disabledForeground
protected Color acceleratorForeground
protected Color acceleratorSelectionForeground
protected String acceleratorDelimiter
'+'
在
'Ctrl+C'
。
protected int defaultTextIconGap
protected Font acceleratorFont
protected MouseInputListener mouseInputListener
protected MenuDragMouseListener menuDragMouseListener
protected MenuKeyListener menuKeyListener
protected PropertyChangeListener propertyChangeListener
PropertyChangeListener
返回
createPropertyChangeListener
。你不需要进入这个领域,而如果你想自定义
PropertyChangeListener
重写
createPropertyChangeListener
。
createPropertyChangeListener(javax.swing.JComponent)
protected Icon arrowIcon
protected Icon checkIcon
protected boolean oldBorderPainted
public static ComponentUI createUI(JComponent c)
public void installUI(JComponent c)
ComponentUI
ComponentUI
实例被安装在指定组件的UI代理。这种方法应该完全配置的组件外观和感觉,包括以下内容:
LayoutManager
组件上的必要。PropertyChangeListener
变化适当。installUI
方法重写,继承类
ComponentUI
c
-组件,UI代理被安装
ComponentUI.uninstallUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
protected void installDefaults()
protected void installComponents(JMenuItem menuItem)
protected String getPropertyPrefix()
protected void installListeners()
protected void installKeyboardActions()
public void uninstallUI(JComponent c)
ComponentUI
installUI
。这个方法被调用时,这个
UIComponent
实例被作为指定组件的UI代理删除。这种方法应该撤消配置进行
installUI
,小心留下的
JComponent
实例在干净的状态(没有多余的听众,外观和感觉的特定属性的对象,等)。这应包括以下几个方面:
uninstallUI
方法重写,继承类
ComponentUI
c
-从这个UI代理被删除的组件;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
ComponentUI.installUI(javax.swing.JComponent)
,
JComponent.updateUI()
protected void uninstallDefaults()
protected void uninstallComponents(JMenuItem menuItem)
protected void uninstallListeners()
protected void uninstallKeyboardActions()
protected MouseInputListener createMouseInputListener(JComponent c)
protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
protected MenuKeyListener createMenuKeyListener(JComponent c)
protected PropertyChangeListener createPropertyChangeListener(JComponent c)
PropertyChangeListener
将被添加到菜单项。如果此方法返回的空值,则不会添加到菜单项中。
PropertyChangeListener
或空的实例
public Dimension getMinimumSize(JComponent c)
ComponentUI
null
返回,最小尺寸将由组件的布局管理器的计算(这是与一个特定的布局管理器安装任何组件的首选方法)。此方法的默认实现调用
getPreferredSize
和返回值。
getMinimumSize
方法重写,继承类
ComponentUI
c
最小尺寸的是被查询的成分;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
Dimension
对象或
null
JComponent.getMinimumSize()
,
LayoutManager.minimumLayoutSize(java.awt.Container)
,
ComponentUI.getPreferredSize(javax.swing.JComponent)
public Dimension getPreferredSize(JComponent c)
ComponentUI
null
返回,首选大小将由组件的布局管理器的计算(这是与一个特定的布局管理器安装任何组件的首选方法)。此方法的默认实现将返回
null
。
getPreferredSize
方法重写,继承类
ComponentUI
c
优先度的被查询的成分;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
JComponent.getPreferredSize()
,
LayoutManager.preferredLayoutSize(java.awt.Container)
public Dimension getMaximumSize(JComponent c)
ComponentUI
null
返回,最大规模将由组件的布局管理器的计算(这是与一个特定的布局管理器安装任何组件的首选方法)。此方法的默认实现调用
getPreferredSize
和返回值。
getMaximumSize
方法重写,继承类
ComponentUI
c
-其最大尺寸被查询的成分;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
Dimension
对象或
null
JComponent.getMaximumSize()
,
LayoutManager2.maximumLayoutSize(java.awt.Container)
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap)
public void update(Graphics g, JComponent c)
update
方法重写,继承类
ComponentUI
g
-其中
Graphics
背景画
c
-正在绘制的构件;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
ComponentUI.paint(java.awt.Graphics, javax.swing.JComponent)
,
JComponent.paintComponent(java.awt.Graphics)
public void paint(Graphics g, JComponent c)
ComponentUI
ComponentUI.update
方法调用时指定的组件正在粉刷。子类应重写此方法,并使用指定的
Graphics
对象呈现的成分含量。
paint
方法重写,继承类
ComponentUI
g
-其中
Graphics
背景画
c
-正在绘制的构件;这种说法常常被忽视,但可能如果UI对象是无状态的,共享由多个组件
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap)
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
g
-绘制的图形
menuItem
菜单项被涂
bgColor
选择背景颜色
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text)
g
图形上下文
menuItem
菜单项呈现
textRect
-边框绘制文本
text
字符串渲染
public MenuElement[] getPath()
protected void doClick(MenuSelectionManager msm)
msm
- menuselectionmanager。视觉反馈和内部簿记任务委托给这menuselectionmanager。如果
null
是作为参数传递,使用的
MenuSelectionManager.defaultManager
。
MenuSelectionManager
,
AbstractButton.doClick(int)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.