模块 java.desktop

类 BasicMenuItemUI

已知子类:
BasicCheckBoxMenuItemUI , BasicMenuUI , BasicRadioButtonMenuItemUI , SynthMenuItemUI

public class BasicMenuItemUI extends MenuItemUI
基本菜单项实现
  • 字段详细信息

    • selectionBackground

      protected Color  selectionBackground
      选择背景的颜色。
    • selectionForeground

      protected Color  selectionForeground
      选择前景的颜色。
    • disabledForeground

      protected Color  disabledForeground
      禁用前景的颜色。
    • acceleratorForeground

      protected Color  acceleratorForeground
      加速器前景的颜色。
    • acceleratorSelectionForeground

      protected Color  acceleratorSelectionForeground
      加速器选择的颜色。
    • acceleratorDelimiter

      protected String  acceleratorDelimiter
      加速器分隔符字符串,例如 'Ctrl+C' 中的 '+'
      自从:
      1.7
    • defaultTextIconGap

      protected int defaultTextIconGap
      文本和图标之间的间隙。
    • acceleratorFont

      protected Font  acceleratorFont
      加速器字体。
    • mouseInputListener

      protected MouseInputListener  mouseInputListener
      MouseInputListener 的实例。
    • propertyChangeListener

      protected PropertyChangeListener  propertyChangeListener
      PropertyChangeListenercreatePropertyChangeListener 返回。您不需要访问此字段,而是如果您想自定义 PropertyChangeListener override createPropertyChangeListener
      自从:
      1.6
      参见:
    • arrowIcon

      protected Icon  arrowIcon
      箭头图标。
    • checkIcon

      protected Icon  checkIcon
      检查图标。
    • oldBorderPainted

      protected boolean oldBorderPainted
      该值表示是否绘制了旧边框。
  • 构造方法详细信息

    • BasicMenuItemUI

      public BasicMenuItemUI()
      构造一个 BasicMenuItemUI
  • 方法详情

    • createUI

      public static ComponentUI  createUI(JComponent  c)
      返回 BasicMenuItemUI 的新实例。
      参数:
      c - 一个组件
      返回:
      BasicMenuItemUI 的新实例
    • installDefaults

      protected void installDefaults()
      安装默认属性。
    • installComponents

      protected void installComponents(JMenuItem  menuItem)
      注册菜单的子组件。
      参数:
      menuItem - 一个菜单项
      自从:
      1.3
    • getPropertyPrefix

      protected String  getPropertyPrefix()
      返回属性前缀。
      返回:
      属性前缀
    • installListeners

      protected void installListeners()
      注册听众。
    • installKeyboardActions

      protected void installKeyboardActions()
      注册键盘操作。
    • uninstallDefaults

      protected void uninstallDefaults()
      卸载默认属性。
    • uninstallComponents

      protected void uninstallComponents(JMenuItem  menuItem)
      注销组件。
      参数:
      menuItem - 一个菜单项
      自从:
      1.3
    • uninstallListeners

      protected void uninstallListeners()
      注销听众。
    • uninstallKeyboardActions

      protected void uninstallKeyboardActions()
      注销键盘操作。
    • createMouseInputListener

      protected MouseInputListener  createMouseInputListener(JComponent  c)
      返回 MouseInputListener 的实例。
      参数:
      c - 一个组件
      返回:
      MouseInputListener 的实例
    • createMenuDragMouseListener

      protected MenuDragMouseListener  createMenuDragMouseListener(JComponent  c)
      返回 MenuDragMouseListener 的实例。
      参数:
      c - 一个组件
      返回:
      MenuDragMouseListener 的实例
    • createMenuKeyListener

      protected MenuKeyListener  createMenuKeyListener(JComponent  c)
      返回 MenuKeyListener 的实例。
      参数:
      c - 一个组件
      返回:
      MenuKeyListener 的实例
    • createPropertyChangeListener

      protected PropertyChangeListener  createPropertyChangeListener(JComponent  c)
      创建一个 PropertyChangeListener ,它将被添加到菜单项中。如果此方法返回 null,则不会将其添加到菜单项。
      参数:
      c - 一个组件
      返回:
      PropertyChangeListener 的实例或 null
      自从:
      1.6
    • getPreferredMenuItemSize

      protected Dimension  getPreferredMenuItemSize(JComponent  c, Icon  checkIcon, Icon  arrowIcon, int defaultTextIconGap)
      返回菜单项的首选大小。
      参数:
      c - 一个组件
      checkIcon - 复选图标
      arrowIcon - 箭头图标
      defaultTextIconGap - 文本和图标之间的间隙
      返回:
      菜单项的首选大小
    • update

      public void update(Graphics  g, JComponent  c)
      我们在 paintMenuItem() 中绘制背景,因此重写更新(默认填充不透明组件的背景)以仅调用 paint()。
      重写:
      update 在类 ComponentUI
      参数:
      g - 绘制的 Graphics 上下文
      c - 正在绘制的组件;这个参数经常被忽略,但如果 UI 对象是无状态的并且由多个组件共享,则可能会被使用
      参见:
    • paintMenuItem

      protected void paintMenuItem(Graphics  g, JComponent  c, Icon  checkIcon, Icon  arrowIcon, Color  background, Color  foreground, int defaultTextIconGap)
      绘制菜单项。
      参数:
      g - Graphics 的实例
      c - 一个组件
      checkIcon - 复选图标
      arrowIcon - 箭头图标
      background - 背景色
      foreground - 前景色
      defaultTextIconGap - 文本和图标之间的间隙
    • paintBackground

      protected void paintBackground(Graphics  g, JMenuItem  menuItem, Color  bgColor)
      绘制菜单项的背景。
      参数:
      g - 油漆图形
      menuItem - 要绘制的菜单项
      bgColor - 选择背景颜色
      自从:
      1.4
    • paintText

      protected void paintText(Graphics  g, JMenuItem  menuItem, Rectangle  textRect, String  text)
      呈现当前菜单项的文本。
      参数:
      g - 图形上下文
      menuItem - 要呈现的菜单项
      textRect - 用于呈现文本的边界矩形
      text - 要呈现的字符串
      自从:
      1.4
    • getPath

      public MenuElement [] getPath()
      返回菜单元素路径。
      返回:
      菜单元素路径
    • doClick

      protected void doClick(MenuSelectionManager  msm)
      当要激活菜单项时调用此方法。此方法处理菜单项激活的一些细节,例如清除所选路径和向 JMenuItem 的 doClick() 方法发送消息。
      参数:
      msm - 菜单选择管理器。视觉反馈和内部簿记任务委托给此 MenuSelectionManager。如果 null 作为此参数传递,则使用 MenuSelectionManager.defaultManager
      自从:
      1.4
      参见: