JavaTM 2 Platform
Standard Ed. 6

javax.swing.plaf.basic
类 BasicOptionPaneUI

java.lang.Object
  继承者 javax.swing.plaf.ComponentUI
      继承者 javax.swing.plaf.OptionPaneUI
          继承者 javax.swing.plaf.basic.BasicOptionPaneUI

public class BasicOptionPaneUI
extends OptionPaneUI

JOptionPane 提供基本外观。BasicMessagePaneUI 提供将图标、消息和按钮置于 Container 中的方法。一般情况下,布局如下所示:

        ------------------
        | i | message    |
        | c | message    |
        | o | message    |
        | n | message    |
        ------------------
        |     buttons    |
        |________________|
 
图标是 Icon 的实例,包装在 JLabel 中。消息是不透明对象,用于测试:如果消息为 Component,则将其添加到 Container;如果其为 Icon,则将其包装在 JLabel 中并添加到 Container,否则将其包装在 JLabel 中。

当选项窗格的 ComponentOrientation 属性为水平的从左到右时,使用上述布局。布局将针对其他方向进行适当调整。

Container、消息、图标和按钮都是根据抽象方法确定的。


嵌套类摘要
 class BasicOptionPaneUI.ButtonActionListener
          此内部类因编译器故障而被标记为“公开”。
static class BasicOptionPaneUI.ButtonAreaLayout
          ButtonAreaLayout 的行为方式类似于 FlowLayout
 class BasicOptionPaneUI.PropertyChangeHandler
          此内部类因编译器故障而被标记为“公开”。
 
字段摘要
protected  boolean hasCustomComponents
          如果 Component 包含在消息或按钮中,则将其设置为 true。
protected  Component initialFocusComponent
          利用 selectInitialValue 传递消息时接收焦点的组件。
protected  JComponent inputComponent
          如果 optionPane.getWantsInput() 返回 true,则 JComponent 提供输入。
static int MinimumHeight
           
protected  Dimension minimumSize
           
static int MinimumWidth
           
protected  JOptionPane optionPane
          接收者为其提供外观的 JOptionPane
protected  PropertyChangeListener propertyChangeListener
           
 
构造方法摘要
BasicOptionPaneUI()
           
 
方法摘要
protected  void addButtonComponents(Container container, Object[] buttons, int initialIndex)
          创建表示 buttons 中每个对象的适当对象并将其添加到 container
protected  void addIcon(Container top)
          创建并添加 JLabel,它表示对 top 调用 getIcon 所返回的图标。
protected  void addMessageComponents(Container container, GridBagConstraints cons, Object msg, int maxll, boolean internallyCreated)
          创建表示 msg 的适当对象并将其置于 container 中。
protected  void burstStringInto(Container c, String d, int maxll)
          递归式创建表示 d 的新 JLabel 实例每个 JLabel 实例都将被添加到 c
 boolean containsCustomComponents(JOptionPane op)
          如果在上一次对 validateComponent 的调用中消息或按钮包含 Component 的子类,则返回 true。
protected  ActionListener createButtonActionListener(int buttonIndex)
           
protected  Container createButtonArea()
          创建并返回包含按钮的 Container。
protected  LayoutManager createLayoutManager()
           
protected  Container createMessageArea()
          从 installComponents 获取消息以创建包含消息正文的 Container。
protected  PropertyChangeListener createPropertyChangeListener()
           
protected  Container createSeparator()
           
static ComponentUI createUI(JComponent x)
          创建一个新的 BasicOptionPaneUI 实例。
protected  Object[] getButtons()
          返回从接收者为其提供外观的 JOptionPane 显示的按钮。
protected  Icon getIcon()
          返回来自接收者为其提供外观的 JOptionPane 的图标,或者从 getDefaultIcon 返回的默认图标。
protected  Icon getIconForType(int messageType)
          返回用于传入类型的图标。
protected  int getInitialValueIndex()
          将初始索引返回给要选择的按钮。
protected  int getMaxCharactersPerLineCount()
          返回要置于行中的最大字符数。
protected  Object getMessage()
          返回从接收者为其提供外观的 JOptionPane 显示的消息。
 Dimension getMinimumOptionPaneSize()
          返回选项窗格应该具有的最小大小。
 Dimension getPreferredSize(JComponent c)
          如果 c 为包含接收者的 JOptionPane,则返回的首选大小为 JOptionPaneLayoutManager 的最大首选大小和 getMinimumOptionPaneSize
protected  boolean getSizeButtonsToSameWidth()
          返回 true,基本 L&F 希望所有按钮具有相同的宽度。
protected  void installComponents()
           
protected  void installDefaults()
           
protected  void installKeyboardActions()
           
protected  void installListeners()
           
 void installUI(JComponent c)
          安装作为传入 JOptionPane 的 L&F 的接收者。
protected  void resetInputValue()
          基于 inputComponent 中的值,设置接收者为其提供外观的选项窗格中的输入值。
 void selectInitialValue(JOptionPane op)
          如果 inputComponent 为非 null,则请求焦点位于其上;否则请求焦点位于默认值上
protected  void uninstallComponents()
           
protected  void uninstallDefaults()
           
protected  void uninstallKeyboardActions()
           
protected  void uninstallListeners()
           
 void uninstallUI(JComponent c)
          从传入拆分窗格的 L&F 控制器移除接收者。
 
从类 javax.swing.plaf.ComponentUI 继承的方法
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, paint, update
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

MinimumWidth

public static final int MinimumWidth
另请参见:
常量字段值

MinimumHeight

public static final int MinimumHeight
另请参见:
常量字段值

optionPane

protected JOptionPane optionPane
接收者为其提供外观的 JOptionPane


minimumSize

protected Dimension minimumSize

inputComponent

protected JComponent inputComponent
如果 optionPane.getWantsInput() 返回 true,则 JComponent 提供输入。


initialFocusComponent

protected Component initialFocusComponent
利用 selectInitialValue 传递消息时接收焦点的组件。


hasCustomComponents

protected boolean hasCustomComponents
如果 Component 包含在消息或按钮中,则将其设置为 true。


propertyChangeListener

protected PropertyChangeListener propertyChangeListener
构造方法详细信息

BasicOptionPaneUI

public BasicOptionPaneUI()
方法详细信息

createUI

public static ComponentUI createUI(JComponent x)
创建一个新的 BasicOptionPaneUI 实例。


installUI

public void installUI(JComponent c)
安装作为传入 JOptionPane 的 L&F 的接收者。

覆盖:
ComponentUI 中的 installUI
参数:
c - 将安装此 UI 委托的组件
另请参见:
ComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

uninstallUI

public void uninstallUI(JComponent c)
从传入拆分窗格的 L&F 控制器移除接收者。

覆盖:
ComponentUI 中的 uninstallUI
参数:
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()

installKeyboardActions

protected void installKeyboardActions()

uninstallKeyboardActions

protected void uninstallKeyboardActions()

getMinimumOptionPaneSize

public Dimension getMinimumOptionPaneSize()
返回选项窗格应该具有的最小大小。主要供希望提供不同最小大小的子类使用。


getPreferredSize

public Dimension getPreferredSize(JComponent c)
如果 c 为包含接收者的 JOptionPane,则返回的首选大小为 JOptionPaneLayoutManager 的最大首选大小和 getMinimumOptionPaneSize

覆盖:
ComponentUI 中的 getPreferredSize
参数:
c - 将查询其首选大小的组件;此参数常被忽略,但如果 UI 对象是无状态的并由多个组件共享,则可以使用该参数
另请参见:
JComponent.getPreferredSize(), LayoutManager.preferredLayoutSize(java.awt.Container)

createMessageArea

protected Container createMessageArea()
从 installComponents 获取消息以创建包含消息正文的 Container。通过调用 addIcon 创建图标。


addMessageComponents

protected void addMessageComponents(Container container,
                                    GridBagConstraints cons,
                                    Object msg,
                                    int maxll,
                                    boolean internallyCreated)
创建表示 msg 的适当对象并将其置于 container 中。如果 msg 为 Component 的实例,则直接添加它;如果其为 Icon,则创建 JLabel 来表示它;否则,如果 d 为 Object[],则为该字符串创建 JLabel,将为其子级递归式调用此方法。如果 Objc 为 Component 的实例并且由此方法内部创建,则 internallyCreated 为 true(仅当 !internallyCreated 时,使用此方法正确设置 hasCustomComponents)。


getMessage

protected Object getMessage()
返回从接收者为其提供外观的 JOptionPane 显示的消息。


addIcon

protected void addIcon(Container top)
创建并添加 JLabel,它表示对 top 调用 getIcon 所返回的图标。此方法获得从 createMessageArea 传递的消息


getIcon

protected Icon getIcon()
返回来自接收者为其提供外观的 JOptionPane 的图标,或者从 getDefaultIcon 返回的默认图标。


getIconForType

protected Icon getIconForType(int messageType)
返回用于传入类型的图标。


getMaxCharactersPerLineCount

protected int getMaxCharactersPerLineCount()
返回要置于行中的最大字符数。


burstStringInto

protected void burstStringInto(Container c,
                               String d,
                               int maxll)
递归式创建表示 d 的新 JLabel 实例每个 JLabel 实例都将被添加到 c


createSeparator

protected Container createSeparator()

createButtonArea

protected Container createButtonArea()
创建并返回包含按钮的 Container。通过调用 getButtons 创建按钮。


addButtonComponents

protected void addButtonComponents(Container container,
                                   Object[] buttons,
                                   int initialIndex)
创建表示 buttons 中每个对象的适当对象并将其添加到 container。这与 addMessageComponents 不同,不同点在于它将在 buttons 上递归,并且如果按钮不是 Component,它将创建一个 JButton 的实例。


createButtonActionListener

protected ActionListener createButtonActionListener(int buttonIndex)

getButtons

protected Object[] getButtons()
返回从接收者为其提供外观的 JOptionPane 显示的按钮。如果 JOptionPane 设置了选项,则提供它们;否则,如果 optionType 为 YES_NO_OPTION,则返回 yesNoOptions;如果类型为 YES_NO_CANCEL_OPTION,则返回 yesNoCancelOptions;否则返回 defaultButtons。


getSizeButtonsToSameWidth

protected boolean getSizeButtonsToSameWidth()
返回 true,基本 L&F 希望所有按钮具有相同的宽度。


getInitialValueIndex

protected int getInitialValueIndex()
将初始索引返回给要选择的按钮。索引是根据 JOptionPane 的初始值和 JOptionPane 的选项计算出的,或者为 0。


resetInputValue

protected void resetInputValue()
基于 inputComponent 中的值,设置接收者为其提供外观的选项窗格中的输入值。


selectInitialValue

public void selectInitialValue(JOptionPane op)
如果 inputComponent 为非 null,则请求焦点位于其上;否则请求焦点位于默认值上

指定者:
OptionPaneUI 中的 selectInitialValue

containsCustomComponents

public boolean containsCustomComponents(JOptionPane op)
如果在上一次对 validateComponent 的调用中消息或按钮包含 Component 的子类,则返回 true。

指定者:
OptionPaneUI 中的 containsCustomComponents

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only