- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.OptionPaneUI
-
- javax.swing.plaf.basic.BasicOptionPaneUI
-
- 已知直接子类:
-
SynthOptionPaneUI
public class BasicOptionPaneUI extends OptionPaneUI
提供JOptionPane的基本外观。BasicMessagePaneUI提供了将图标,消息和按钮放入Container。 通常,布局将如下所示:------------------ | i | message | | c | message | | o | message | | n | message | ------------------ | buttons | |________________|icon是Icon一个实例,它包含在JLabel。 该消息是一个不透明的对象,并测试以下内容:如果消息是Component它被添加到Container,如果它是Icon它被包装在JLabel并添加到Container否则它被包装在JLabel。当选项窗格的
ComponentOrientation属性为水平,从左到右时,将使用上面的布局。 布局将根据其他方向进行适当调整。Container,消息,图标和按钮都是从抽象方法确定的。
-
-
嵌套类汇总
嵌套类 变量和类型 类 描述 classBasicOptionPaneUI.ButtonActionListener该类应被视为“受保护”的内部类。static classBasicOptionPaneUI.ButtonAreaLayoutButtonAreaLayout行为方式与FlowLayout类似。classBasicOptionPaneUI.PropertyChangeHandler该类应被视为“受保护”的内部类。
-
字段汇总
字段 变量和类型 字段 描述 protected booleanhasCustomComponents如果组件包含在消息或按钮中,则在validateComponent中设置为true。protected ComponentinitialFocusComponent使用selectInitialValue发送消息时接收焦点的组件。protected JComponentinputComponent如果optionPane.getWantsInput()返回true,则JComponent提供输入。static intMinimumHeightJOptionPane高度为JOptionPane。protected DimensionminimumSize大小为JOptionPane。static intMinimumWidthJOptionPane宽度为JOptionPane。protected JOptionPaneoptionPane接收器提供外观和感觉的JOptionPane。protected PropertyChangeListenerpropertyChangeListenerPropertyChangeListener的实例。
-
构造方法摘要
构造方法 构造器 描述 BasicOptionPaneUI()
-
方法摘要
所有方法 静态方法 实例方法 具体的方法 变量和类型 方法 描述 protected voidaddButtonComponents(Container container, Object[] buttons, int initialIndex)创建适当的对象以表示buttons每个对象,并将其添加到container。protected voidaddIcon(Container top)创建并添加一个JLabel代表从返回的图标getIcon至top。protected voidaddMessageComponents(Container container, GridBagConstraints cons, Object msg, int maxll, boolean internallyCreated)创建表示msg的相应对象,并将其放入container。protected voidburstStringInto(Container c, String d, int maxll)递归创建新的JLabel实例以表示d。booleancontainsCustomComponents(JOptionPane op)如果在上次调用validateComponent时消息或按钮包含Component的子类,则返回true。protected ActionListenercreateButtonActionListener(int buttonIndex)构造ButtonActionListener的新实例。protected ContainercreateButtonArea()创建并返回包含按钮的Container。protected LayoutManagercreateLayoutManager()返回布局管理器。protected ContainercreateMessageArea()从installComponents传递消息,创建一个包含消息正文的Container。protected PropertyChangeListenercreatePropertyChangeListener()返回PropertyChangeListener的实例。protected ContainercreateSeparator()返回一个分隔符。static ComponentUIcreateUI(JComponent x)创建一个新的BasicOptionPaneUI实例。protected Object[]getButtons()返回接收器提供外观的JOptionPane显示的按钮。protected IcongetIcon()返回接收器提供外观的JOptionPane中的图标,或从getDefaultIcon返回的默认图标。protected IcongetIconForType(int messageType)返回用于传入类型的图标。protected intgetInitialValueIndex()将初始索引返回到要选择的按钮中。protected intgetMaxCharactersPerLineCount()返回要放在一行上的最大字符数。protected ObjectgetMessage()返回要从接收器提供外观的JOptionPane显示的消息。DimensiongetMinimumOptionPaneSize()返回选项窗格应该是的最小大小。DimensiongetPreferredSize(JComponent c)如果c是JOptionPane接收机被包含在,则返回,优选的尺寸为最大的的优选尺寸的LayoutManager为JOptionPane,和getMinimumOptionPaneSize。protected booleangetSizeButtonsToSameWidth()返回true,基本L&F希望所有按钮具有相同的宽度。protected voidinstallComponents()注册组件。protected voidinstallDefaults()安装默认属性。protected voidinstallKeyboardActions()注册键盘操作。protected voidinstallListeners()注册听众。voidinstallUI(JComponent c)将接收器安装为传入JOptionPane的L&F。protected voidresetInputValue()根据inputComponent中的值,在接收器提供外观的选项窗格中设置输入值。voidselectInitialValue(JOptionPane op)如果inputComponent为非null,则请求焦点,否则请求焦点于默认值protected voiduninstallComponents()取消注册组件。protected voiduninstallDefaults()卸载默认属性。protected voiduninstallKeyboardActions()取消注册键盘操作。protected voiduninstallListeners()取消注册听众。voiduninstallUI(JComponent c)从传入的拆分窗格的L&F控制器中删除接收器。-
声明方法的类 javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, paint, update
-
-
-
-
字段详细信息
-
MinimumWidth
public static final int MinimumWidth
JOptionPane宽度为JOptionPane。- 另请参见:
- 常数字段值
-
MinimumHeight
public static final int MinimumHeight
JOptionPane高度为JOptionPane。- 另请参见:
- 常数字段值
-
optionPane
protected JOptionPane optionPane
JOptionPane,接收器提供外观和感觉。
-
minimumSize
protected Dimension minimumSize
大小为JOptionPane。
-
inputComponent
protected JComponent inputComponent
如果optionPane.getWantsInput()返回true,则JComponent提供输入。
-
initialFocusComponent
protected Component initialFocusComponent
使用selectInitialValue发送消息时接收焦点的组件。
-
hasCustomComponents
protected boolean hasCustomComponents
如果组件包含在消息或按钮中,则在validateComponent中设置为true。
-
propertyChangeListener
protected PropertyChangeListener propertyChangeListener
PropertyChangeListener的实例。
-
-
方法详细信息
-
createUI
public static ComponentUI createUI(JComponent x)
创建一个新的BasicOptionPaneUI实例。- 参数
-
x- 组件 - 结果
-
一个新的
BasicOptionPaneUI实例
-
installUI
public void installUI(JComponent c)
将接收器安装为传入JOptionPane的L&F。- 重写:
-
installUI类ComponentUI - 参数
-
c- 正在安装此UI委托的组件 - 另请参见:
-
ComponentUI.uninstallUI(javax.swing.JComponent),JComponent.setUI(javax.swing.plaf.ComponentUI),JComponent.updateUI()
-
uninstallUI
public void uninstallUI(JComponent c)
从传入的拆分窗格的L&F控制器中删除接收器。- 重写:
-
uninstallUI在类ComponentUI - 参数
-
c- 从中删除此UI委托的组件; 此参数通常被忽略,但如果UI对象是无状态的并且由多个组件共享,则可以使用此参数 - 另请参见:
-
ComponentUI.installUI(javax.swing.JComponent),JComponent.updateUI()
-
installDefaults
protected void installDefaults()
安装默认属性。
-
uninstallDefaults
protected void uninstallDefaults()
卸载默认属性。
-
installComponents
protected void installComponents()
注册组件。
-
uninstallComponents
protected void uninstallComponents()
取消注册组件。
-
createLayoutManager
protected LayoutManager createLayoutManager()
返回布局管理器。- 结果
- 布局管理员
-
installListeners
protected void installListeners()
注册听众。
-
uninstallListeners
protected void uninstallListeners()
取消注册听众。
-
createPropertyChangeListener
protected PropertyChangeListener createPropertyChangeListener()
返回PropertyChangeListener的实例。- 结果
-
PropertyChangeListener一个实例
-
installKeyboardActions
protected void installKeyboardActions()
注册键盘操作。
-
uninstallKeyboardActions
protected void uninstallKeyboardActions()
取消注册键盘操作。
-
getMinimumOptionPaneSize
public Dimension getMinimumOptionPaneSize()
返回选项窗格应该是的最小大小。 主要为希望提供不同最小尺寸的子类提供。- 结果
- 选项窗格的最小大小
-
getPreferredSize
public Dimension getPreferredSize(JComponent c)
如果c是JOptionPane接收机被包含在,则返回,优选的尺寸为最大的的优选尺寸的LayoutManager为JOptionPane,和getMinimumOptionPaneSize。- 重写:
-
getPreferredSize类ComponentUI - 参数
-
c- 正在查询其首选大小的组件; 此参数通常被忽略,但如果UI对象是无状态的并且由多个组件共享,则可以使用此参数 - 结果
-
包含给定组件的首选大小的
Dimension对象,适合外观 - 另请参见:
-
JComponent.getPreferredSize(),LayoutManager.preferredLayoutSize(java.awt.Container)
-
createMessageArea
protected Container createMessageArea()
从installComponents传递消息以创建包含消息正文的Container。 该图标是通过致电addIcon创建的。- 结果
-
Container的实例
-
addMessageComponents
protected void addMessageComponents(Container container, GridBagConstraints cons, Object msg, int maxll, boolean internallyCreated)
创建表示msg的相应对象,并将其放入container。 如果msg是实例Component,它被直接加入; 如果它是Icon,则创建一个JLabel来表示它; 否则,为字符串创建JLabel。 如果msg是Object [],则将为子msg递归调用此方法。internallyCreated是true如果msg是实例Component,并通过该方法内部创建的(这被用来正确地设定hasCustomComponents仅当internallyCreated是false)。- 参数
-
container- 一个容器 -
cons-实例GridBagConstraints -
msg- 消息 -
maxll- 最大长度 -
internallyCreated-true如果组件是内部创建的
-
getMessage
protected Object getMessage()
返回要从接收器提供外观的JOptionPane显示的消息。- 结果
- 要显示的消息
-
addIcon
protected void addIcon(Container top)
创建并添加一个JLabel,表示从getIcon返回的图标到top。 这是来自createMessageArea。- 参数
-
top- 一个容器
-
getIcon
protected Icon getIcon()
返回接收器提供外观的JOptionPane中的图标,或从getDefaultIcon返回的默认图标。- 结果
- 图标
-
getIconForType
protected Icon getIconForType(int messageType)
返回用于传入类型的图标。- 参数
-
messageType- 一种消息 - 结果
- 用于传入类型的图标
-
getMaxCharactersPerLineCount
protected int getMaxCharactersPerLineCount()
返回要放在一行上的最大字符数。- 结果
- 一行中放置的最大字符数
-
burstStringInto
protected void burstStringInto(Container c, String d, int maxll)
递归创建新的JLabel实例以表示d。 每个JLabel实例都添加到c。- 参数
-
c- 一个容器 -
d- 文字 -
maxll- 文本的最大长度
-
createSeparator
protected Container createSeparator()
返回一个分隔符。- 结果
- 分隔符
-
createButtonArea
protected Container createButtonArea()
创建并返回包含按钮的Container。 通过调用getButtons创建按钮。- 结果
-
包含按钮的
Container
-
addButtonComponents
protected void addButtonComponents(Container container, Object[] buttons, int initialIndex)
创建适当的对象以表示buttons每个对象,并将其添加到container。 这与addMessageComponents的不同之处在于它将在buttons递归,如果按钮不是Component,它将创建一个JButton实例。- 参数
-
container- 一个容器 -
buttons- 一组按钮 -
initialIndex- 初始索引
-
createButtonActionListener
protected ActionListener createButtonActionListener(int buttonIndex)
构造ButtonActionListener的新实例。- 参数
-
buttonIndex- 按钮的索引 - 结果
-
ButtonActionListener的新实例
-
getButtons
protected Object[] getButtons()
返回接收器提供外观的JOptionPane显示按钮。 如果JOptionPane有选项设置,他们将被提供,否则,如果optionType为YES_NO_OPTION,yesNoOptions返回,如果类型为YES_NO_CANCEL_OPTIONyesNoCancelOptions返回,否则defaultButtons返回。- 结果
- 从JOptionPane显示的按钮
-
getSizeButtonsToSameWidth
protected boolean getSizeButtonsToSameWidth()
返回true,基本L&F希望所有按钮具有相同的宽度。- 结果
-
true如果所有按钮应具有相同的宽度
-
getInitialValueIndex
protected int getInitialValueIndex()
将初始索引返回到要选择的按钮中。 索引是根据JOptionPane的初始值和JOptionPane的选项或0计算的。- 结果
- 初始索引进入要选择的按钮
-
resetInputValue
protected void resetInputValue()
根据inputComponent中的值,在接收器提供外观的选项窗格中设置输入值。
-
selectInitialValue
public void selectInitialValue(JOptionPane op)
如果inputComponent为非null,则请求焦点,否则请求焦点于默认值- Specified by:
-
selectInitialValue,类OptionPaneUI - 参数
-
op- aJOptionPane
-
containsCustomComponents
public boolean containsCustomComponents(JOptionPane op)
如果在上次调用validateComponent时消息或按钮包含Component的子类,则返回true。- Specified by:
-
containsCustomComponents类,OptionPaneUI - 参数
-
op- aJOptionPane - 结果
-
true如果给定的JOptionPane包含用户创建的Components
-
-