java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.OptionPaneUI
javax.swing.plaf.basic.BasicOptionPaneUI
- 直接已知的子类:
-
SynthOptionPaneUI
为
JOptionPane提供基本的外观。 BasicMessagePaneUI提供了一种将图标、消息和按钮放入Container的方法。通常,布局如下所示:
------------------
| i | message |
| c | message |
| o | message |
| n | message |
------------------
| buttons |
|________________|
图标是Icon的一个实例,被包装在JLabel中。消息是一个不透明对象,并根据以下内容进行测试:如果消息是一个Component,则将其添加到Container中;如果是一个Icon,则将其包装在JLabel中并添加到Container中;否则将其包装在JLabel中。
当选项窗格的ComponentOrientation属性为水平,从左到右时,将使用上述布局。对于其他方向,布局将适当调整。
Container、消息、图标和按钮都是从抽象方法中确定的。
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass应将此类视为“protected”内部类。static classButtonAreaLayout的行为类似于FlowLayout。class应将此类视为“protected”内部类。 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean如果在validateComponent中包含消息或按钮中包含组件,则设置为true。protected Component在使用selectInitialValue消息时,用于接收焦点的组件。protected JComponent如果optionPane.getWantsInput()返回true,则为输入提供的JComponent。static final intJOptionPane的最小高度。protected DimensionJOptionPane的大小。static final intJOptionPane的最小宽度。protected JOptionPane为其提供外观的JOptionPane。protected PropertyChangeListenerPropertyChangeListener的实例。 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddButtonComponents(Container container, Object[] buttons, int initialIndex) 创建适当的对象来表示buttons中的每个对象,并将其添加到container中。protected void创建并添加一个表示从getIcon返回的图标的JLabel到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。boolean如果在上次调用validateComponent时,消息或按钮中包含组件的子类,则返回true。protected ActionListenercreateButtonActionListener(int buttonIndex) 构造一个ButtonActionListener的新实例。protected Container创建并返回一个包含按钮的Container。protected LayoutManager返回一个布局管理器。protected Container从installComponents中调用,创建一个包含消息主体的Container。protected PropertyChangeListener返回一个PropertyChangeListener的实例。protected Container返回一个分隔符。static ComponentUI创建一个新的BasicOptionPaneUI实例。protected Object[]从为其提供外观的JOptionPane中返回要显示的按钮。protected IcongetIcon()从为其提供外观的JOptionPane中返回图标,或者从getDefaultIcon返回默认图标。protected IcongetIconForType(int messageType) 返回要用于传入类型的图标。protected int返回要选择的按钮的初始索引。protected int返回要放置在一行上的最大字符数。protected Object从为其提供外观的JOptionPane中返回要显示的消息。返回选项窗格应该具有的最小大小。如果c是包含接收器的JOptionPane,则返回的首选大小是JOptionPane的LayoutManager的首选大小和getMinimumOptionPaneSize的最大值。protected boolean返回true,基本L&F希望所有按钮具有相同的宽度。protected void注册组件。protected void安装默认属性。protected void注册键盘操作。protected void注册监听器。void将接收器安装为传入JOptionPane的L&F。protected void根据inputComponent中的值,在为其提供外观的选项窗格中设置输入值。void如果inputComponent非空,则请求焦点在其上,否则请求焦点在默认值上。protected void注销组件。protected void卸载默认属性。protected void注销键盘操作。protected void注销监听器。void从传入的分割窗格的L&F控制器中移除接收器。Methods declared in class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, paint, update
-
Field Details
-
MinimumWidth
public static final int MinimumWidthJOptionPane的最小宽度。- 参见:
-
MinimumHeight
public static final int MinimumHeightJOptionPane的最小高度。- 参见:
-
optionPane
为其提供外观的JOptionPane。 -
minimumSize
JOptionPane的大小。 -
inputComponent
如果optionPane.getWantsInput()返回true,则为输入提供的JComponent。 -
initialFocusComponent
在使用selectInitialValue消息时,用于接收焦点的组件。 -
hasCustomComponents
protected boolean hasCustomComponents如果在validateComponent中包含消息或按钮中包含组件,则设置为true。 -
propertyChangeListener
PropertyChangeListener的实例。
-
-
Constructor Details
-
BasicOptionPaneUI
public BasicOptionPaneUI()构造一个BasicOptionPaneUI。
-
-
Method Details
-
createUI
创建一个新的BasicOptionPaneUI实例。- 参数:
-
x- 组件 - 返回:
-
一个新的
BasicOptionPaneUI实例
-
installUI
将接收器安装为传入的JOptionPane的L&F。- 覆盖:
-
installUI在类ComponentUI中 - 参数:
-
c- 正在安装此UI委托的组件 - 参见:
-
uninstallUI
从传入的分割窗格的L&F控制器中移除接收器。- 覆盖:
-
uninstallUI在类ComponentUI中 - 参数:
-
c- 正在移除此UI委托的组件;通常忽略此参数,但如果UI对象是无状态的并且由多个组件共享,则可能会使用 - 参见:
-
installDefaults
protected void installDefaults()安装默认属性。 -
uninstallDefaults
protected void uninstallDefaults()卸载默认属性。 -
installComponents
protected void installComponents()注册组件。 -
uninstallComponents
protected void uninstallComponents()注销组件。 -
createLayoutManager
返回一个布局管理器。- 返回:
- 一个布局管理器
-
installListeners
protected void installListeners()注册监听器。 -
uninstallListeners
protected void uninstallListeners()注销监听器。 -
createPropertyChangeListener
返回一个PropertyChangeListener的实例。- 返回:
-
一个
PropertyChangeListener的实例
-
installKeyboardActions
protected void installKeyboardActions()注册键盘操作。 -
uninstallKeyboardActions
protected void uninstallKeyboardActions()注销键盘操作。 -
getMinimumOptionPaneSize
返回选项窗格应该具有的最小大小。主要为希望提供不同最小大小的子类提供。- 返回:
- 选项窗格的最小大小
-
getPreferredSize
如果c是包含接收器的JOptionPane,则返回的首选大小是JOptionPane的LayoutManager的首选大小和getMinimumOptionPaneSize的最大值。- 覆盖:
-
getPreferredSize在类ComponentUI中 - 参数:
-
c- 正在查询其首选大小的组件;通常忽略此参数,但如果UI对象是无状态的并且由多个组件共享,则可能会使用 - 返回:
-
包含给定组件的适合外观的首选大小的
Dimension对象 - 参见:
-
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是Component的实例并且是由此方法内部创建的,则internallyCreated为true(仅当internallyCreated为false时才正确设置hasCustomComponents)。- 参数:
-
container- 一个容器 -
cons- 一个GridBagConstraints实例 -
msg- 一条消息 -
maxll- 最大长度 -
internallyCreated- 如果组件是内部创建的,则为true
-
getMessage
返回JOptionPane提供外观和感觉的消息以显示。- 返回:
- 要显示的消息
-
addIcon
创建并添加一个代表从getIcon返回的图标的JLabel到top。这是从createMessageArea发送的消息。- 参数:
-
top- 一个容器
-
getIcon
返回JOptionPane提供外观和感觉的图标,或者从getDefaultIcon返回的默认图标。- 返回:
- 图标
-
getIconForType
返回用于传入类型的图标。- 参数:
-
messageType- 一种消息类型 - 返回:
- 用于传入类型的图标
-
getMaxCharactersPerLineCount
protected int getMaxCharactersPerLineCount()返回放置在一行上的最大字符数。- 返回:
- 放置在一行上的最大字符数
-
burstStringInto
递归创建新的JLabel实例来表示d。每个JLabel实例都添加到c。- 参数:
-
c- 一个容器 -
d- 一段文本 -
maxll- 文本的最大长度
-
createSeparator
返回一个分隔符。- 返回:
- 一个分隔符
-
createButtonArea
创建并返回包含按钮的Container。通过调用getButtons创建按钮。- 返回:
-
包含按钮的
Container
-
addButtonComponents
创建适当的对象来表示buttons中的每个对象,并将其添加到container。与 addMessageComponents 不同的是,它将在buttons上递归,并且如果按钮不是一个组件,则会创建一个 JButton 实例。- 参数:
-
container- 一个容器 -
buttons- 一个按钮数组 -
initialIndex- 初始索引
-
createButtonActionListener
构造一个新的ButtonActionListener实例。- 参数:
-
buttonIndex- 按钮的索引 - 返回:
-
一个新的
ButtonActionListener实例
-
getButtons
从JOptionPane返回要显示的按钮,该JOptionPane为其提供外观和感觉。如果JOptionPane设置了选项,则将提供它们,否则如果 optionType 是YES_NO_OPTION,则返回yesNoOptions,如果类型是YES_NO_CANCEL_OPTION,则返回yesNoCancelOptions,否则返回defaultButtons。- 返回:
- 从 JOptionPane 返回要显示的按钮
-
getSizeButtonsToSameWidth
protected boolean getSizeButtonsToSameWidth()返回true,基本 L&F 希望所有按钮具有相同的宽度。- 返回:
-
如果所有按钮应具有相同的宽度,则为
true
-
getInitialValueIndex
protected int getInitialValueIndex()返回选择的按钮的初始索引。该索引是从 JOptionPane 的初始值和 JOptionPane 的选项或 0 计算得出的。- 返回:
- 选择的按钮的初始索引
-
resetInputValue
protected void resetInputValue()根据 inputComponent 中的值在提供外观和感觉的选项面板中设置输入值。 -
selectInitialValue
如果 inputComponent 不为 null,则请求焦点在其上,否则请求焦点在默认值上。- 在类中指定:
-
selectInitialValue在类OptionPaneUI中 - 参数:
-
op- 一个JOptionPane
-
containsCustomComponents
如果在上次调用 validateComponent 时消息或按钮包含 Component 的子类,则返回 true。- 在类中指定:
-
containsCustomComponents在类OptionPaneUI中 - 参数:
-
op- 一个JOptionPane - 返回:
-
如果给定的
JOptionPane包含用户创建的Component,则返回true
-