- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.MenuBarUI
-
- javax.swing.plaf.basic.BasicMenuBarUI
-
- 已知直接子类:
-
MetalMenuBarUI,SynthMenuBarUI
public class BasicMenuBarUI extends MenuBarUI
MenuBarUI的默认L&F实现。 这个实现是一个“组合的”视图/控制器。
-
-
Field Summary
Fields Modifier and Type Field 描述 protected ChangeListenerchangeListener实例ChangeListener。protected ContainerListenercontainerListener实例ContainerListener。protected JMenuBarmenuBar实例JMenuBar。
-
构造方法摘要
构造方法 Constructor 描述 BasicMenuBarUI()
-
方法摘要
所有方法 静态方法 接口方法 具体的方法 Modifier and Type 方法 描述 protected ChangeListenercreateChangeListener()返回一个ChangeListener的实例。protected ContainerListenercreateContainerListener()返回一个ContainerListener的实例。static ComponentUIcreateUI(JComponent x)返回一个新的实例BasicMenuBarUI。DimensiongetMaximumSize(JComponent c)返回指定组件的最大尺寸,适合外观和感觉。DimensiongetMinimumSize(JComponent c)返回指定组件的最小尺寸,适合外观和感觉。protected voidinstallDefaults()安装默认属性。protected voidinstallKeyboardActions()注册键盘操作。protected voidinstallListeners()注册听众。voidinstallUI(JComponent c)适当地配置指定的组件的外观和感觉。protected voiduninstallDefaults()卸载默认属性。protected voiduninstallKeyboardActions()取消注册键盘操作。protected voiduninstallListeners()取消注册听众。voiduninstallUI(JComponent c)在installUI反转在指定组件上完成的配置。-
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getPreferredSize, paint, update
-
-
-
-
字段详细信息
-
menuBar
protected JMenuBar menuBar
实例JMenuBar。
-
containerListener
protected ContainerListener containerListener
实例ContainerListener。
-
changeListener
protected ChangeListener changeListener
实例ChangeListener。
-
-
方法详细信息
-
createUI
public static ComponentUI createUI(JComponent x)
返回一个新的实例BasicMenuBarUI。- 参数
-
x- 一个组件 - 结果
-
一个新的例子
BasicMenuBarUI
-
installUI
public void installUI(JComponent c)
描述从类复制:ComponentUI适当地配置指定的组件的外观和感觉。 当正在安装ComponentUI实例作为指定组件上的UI委托时,将调用此方法。 该方法应该完全配置组件的外观,包括以下内容:- 为组件上的颜色,字体,边框,图标,不透明度等安装默认属性值。 只要有可能,由客户端程序初始化的属性值不应该被重写。
- 如有必要,请在组件上安装
LayoutManager。 - 创建/添加任何所需的子组件到组件。
- 在组件上创建/安装事件监听器。
- 在组件上创建/安装
PropertyChangeListener,以便适当地检测和响应组件属性的更改。 - 在组件上安装键盘UI(助记符,遍历等)。
- 初始化任何适当的实例数据。
- 重写:
-
installUI在ComponentUI - 参数
-
c- 正在安装此UIc的组件 - 另请参见:
-
ComponentUI.uninstallUI(javax.swing.JComponent),JComponent.setUI(javax.swing.plaf.ComponentUI),JComponent.updateUI()
-
installDefaults
protected void installDefaults()
安装默认属性。
-
installListeners
protected void installListeners()
注册听众。
-
installKeyboardActions
protected void installKeyboardActions()
注册键盘操作。
-
uninstallUI
public void uninstallUI(JComponent c)
描述从类复制:ComponentUI在installUI反转在指定组件上完成的配置。 当该UIComponent实例作为指定组件的UI委托被删除时,将调用此方法。 该方法应该撤销在installUI执行的配置,小心将JComponent实例保持在干净的状态(没有无关的侦听器,特定于外观的属性对象等)。 这应该包括以下内容:- 从组件中删除任何UI集边框。
- 删除组件上的任何UI集布局管理器。
- 从组件中删除任何添加了UI的子组件。
- 从组件中删除任何UI添加的事件/属性侦听器。
- 从组件中删除任何UI安装的键盘UI。
- 对任何分配的实例数据对象进行空白以允许GC。
- 重写:
-
uninstallUI在ComponentUI - 参数
-
c- 从中删除此UIc的组件; 这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用 - 另请参见:
-
ComponentUI.installUI(javax.swing.JComponent),JComponent.updateUI()
-
uninstallDefaults
protected void uninstallDefaults()
卸载默认属性。
-
uninstallListeners
protected void uninstallListeners()
取消注册听众。
-
uninstallKeyboardActions
protected void uninstallKeyboardActions()
取消注册键盘操作。
-
createContainerListener
protected ContainerListener createContainerListener()
返回一个ContainerListener的实例。- 结果
-
一个
ContainerListener
-
createChangeListener
protected ChangeListener createChangeListener()
返回一个ChangeListener的实例。- 结果
-
一个
ChangeListener
-
getMinimumSize
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)
-
getMaximumSize
public Dimension getMaximumSize(JComponent c)
描述从类复制:ComponentUI返回指定组件的最大尺寸,适合外观和感觉。 如果返回null,则最大大小将由组件的布局管理器计算(这是安装了特定布局管理器的任何组件的首选方法)。 此方法的默认实现将调用getPreferredSize并返回该值。- 重写:
-
getMaximumSize在ComponentUI - 参数
-
c- 查询最大大小的组件; 这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用 - 结果
-
一个
Dimension对象或null - 另请参见:
-
JComponent.getMaximumSize(),LayoutManager2.maximumLayoutSize(java.awt.Container)
-
-