Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing.plaf.basic
Class BasicOptionPaneUI

    java.lang.Object
      |
      +--javax.swing.plaf.ComponentUI
            |
            +--javax.swing.plaf.OptionPaneUI
                  |
                  +--javax.swing.plaf.basic.BasicOptionPaneUI

public class BasicOptionPaneUI
extends OptionPaneUI

Provides the basic look and feel for a JOptionPane. BasicMessagePaneUI provides a means to place an icon, message and buttons into a Container. The layout will look like:

            ------------------
            | i | message    |
            | c | message    |
            | o | message    |
            | n | message    |
            ------------------
            |     buttons    |
            |________________|

icon is an instance of Icon that is wraped inside a JLabel. The message is an opaque object and is tested for the following: if the message is a Component it is added to the Container, if it is an Icon it is wrapped inside a JLabel and added to the Container otherwise it is wrapped inside a JLabel.

The Container, message, icon, and buttons are all determined from abstract methods.

Inner Class Summary
`class` | `BasicOptionPaneUI.ButtonActionListener` This inner class is marked "public" due to a compiler bug.
`static class` | `BasicOptionPaneUI.ButtonAreaLayout` ButtonAreaLayout acts similiar to FlowLayout.
`class` | `BasicOptionPaneUI.PropertyChangeHandler` This inner class is marked "public" due to a compiler bug.

Field Summary
`protected boolean` | `hasCustomComponents` This is set to true in validateComponent if a Component is contained in either the message or the buttons.
`protected java.awt.Component` | `initialFocusComponent` Component to receive focus when messaged with selectInitialValue.
`protected JComponent` | `inputComponent` JComponent provide for input if optionPane.getWantsInput() returns true.
`static int` | `MinimumHeight`
`protected java.awt.Dimension` | `minimumSize`
`static int` | `MinimumWidth`
`protected JOptionPane` | `optionPane` JOptionPane that the reciever is providing the look and feel for.
`protected java.beans.PropertyChangeListener` | `propertyChangeListener`

Constructor Summary
`BasicOptionPaneUI()`

Method Summary
`protected void` | `addButtonComponents(java.awt.Container container, java.lang.Object[] buttons, int initialIndex)` Creates the appropriate object to represent each of the objects in `buttons` and adds it to `container`.
`protected void` | `addIcon(java.awt.Container top)` Creates and adds a JLabel representing the icon returned from `getIcon` to `top`.
`protected void` | `addMessageComponents(java.awt.Container container, java.awt.GridBagConstraints cons, java.lang.Object msg, int maxll, boolean internallyCreated)` Creates the appropriate object to represent `msg` and places it into `container`.
`protected void` | `burstStringInto(java.awt.Container c, java.lang.String d, int maxll)` Recursively creates new JLabel instances to represent `d`.
`boolean` | `containsCustomComponents(JOptionPane op)` Returns true if in the last call to validateComponent the message or buttons contained a subclass of Component.
`protected java.awt.event.ActionListener` | `createButtonActionListener(int buttonIndex)`
`protected java.awt.Container` | `createButtonArea()` Creates and returns a Container containin the buttons.
`protected java.awt.LayoutManager` | `createLayoutManager()`
`protected java.awt.Container` | `createMessageArea()` Messaged from installComponents to create a Container containing the body of the message.
`protected java.beans.PropertyChangeListener` | `createPropertyChangeListener()`
`protected java.awt.Container` | `createSeparator()`
`static ComponentUI` | `createUI(JComponent x)` Creates a new BasicOptionPaneUI instance.
`protected java.lang.Object[]` | `getButtons()` Returns the buttons to display from the JOptionPane the receiver is providing the look and feel for.
`protected Icon` | `getIcon()` Returns the icon from the JOptionPane the reciever is providing the look and feel for, or the default icon as returned from getDefaultIcon.
`protected Icon` | `getIconForType(int messageType)` Returns the icon to use for the passed in type.
`protected int` | `getInitialValueIndex()` Returns the initial index into the buttons to select.
`protected int` | `getMaxCharactersPerLineCount()` Returns the maximum number of characters to place on a line.
`java.awt.Dimension` | `getMaximumSize(JComponent c)` Messages getPreferredSize.
`protected java.lang.Object` | `getMessage()` Returns the message to display from the JOptionPane the receiver is providing the look and feel for.
`java.awt.Dimension` | `getMinimumOptionPaneSize()` Returns the minimum size the option pane should be.
`java.awt.Dimension` | `getMinimumSize(JComponent c)` Messages getPreferredSize.
`java.awt.Dimension` | `getPreferredSize(JComponent c)` If c is the JOptionPane the reciever is contained in, the preferred size that is returned is the maximum of the preferred size of the LayoutManager for the JOptionPane, and `getMinimumOptionPaneSize`.
`protected boolean` | `getSizeButtonsToSameWidth()` Returns true, basic L&F wants all the buttons to have the same width.
`protected void` | `installComponents()`
`protected void` | `installDefaults()`
`protected void` | `installKeyboardActions()`
`protected void` | `installListeners()`
`void` | `installUI(JComponent c)` Installs the reciever as the L&F for the passed in JOptionPane
`protected void` | `resetInputValue()` Sets the input value in the option pane the receiver is providing the look and feel for based on the value in the inputComponent.
`void` | `selectInitialValue(JOptionPane op)` If inputComponent is non-null, the focus is requested on that, otherwise request focus on the default value
`protected void` | `uninstallComponents()`
`protected void` | `uninstallDefaults()`
`protected void` | `uninstallKeyboardActions()`
`protected void` | `uninstallListeners()`
`void` | `uninstallUI(JComponent c)` Removes the receiver from the L&F controller of the passed in split pane.

Methods inherited from class javax.swing.plaf.ComponentUI
`contains, getAccessibleChild, getAccessibleChildrenCount, paint, update`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MinimumWidth

    public static final int MinimumWidth

### MinimumHeight

    public static final int MinimumHeight

### optionPane

    protected JOptionPane optionPane

  JOptionPane that the reciever is providing the look and feel for.

### minimumSize

    protected java.awt.Dimension minimumSize

### inputComponent

    protected JComponent inputComponent

  JComponent provide for input if optionPane.getWantsInput() returns true.

### initialFocusComponent

    protected java.awt.Component initialFocusComponent

  Component to receive focus when messaged with selectInitialValue.

### hasCustomComponents

    protected boolean hasCustomComponents

  This is set to true in validateComponent if a Component is contained in either the message or the buttons.

### propertyChangeListener

    protected java.beans.PropertyChangeListener propertyChangeListener

Constructor Detail

### BasicOptionPaneUI

    public BasicOptionPaneUI()

Method Detail

### createUI

    public static ComponentUI createUI(JComponent x)

  Creates a new BasicOptionPaneUI instance.

### installUI

    public void installUI(JComponent c)

  Installs the reciever as the L&F for the passed in JOptionPane
  Overrides:
    installUI in class ComponentUI

### uninstallUI

    public void uninstallUI(JComponent c)

  Removes the receiver from the L&F controller of the passed in split pane.
  Overrides:
    uninstallUI in class ComponentUI

### installDefaults

    protected void installDefaults()

### uninstallDefaults

    protected void uninstallDefaults()

### installComponents

    protected void installComponents()

### uninstallComponents

    protected void uninstallComponents()

### createLayoutManager

    protected java.awt.LayoutManager createLayoutManager()

### installListeners

    protected void installListeners()

### uninstallListeners

    protected void uninstallListeners()

### createPropertyChangeListener

    protected java.beans.PropertyChangeListener createPropertyChangeListener()

### installKeyboardActions

    protected void installKeyboardActions()

### uninstallKeyboardActions

    protected void uninstallKeyboardActions()

### getMinimumOptionPaneSize

    public java.awt.Dimension getMinimumOptionPaneSize()

  Returns the minimum size the option pane should be. Primarily provided for subclassers wishin to offer a different minimum size.

### getPreferredSize

    public java.awt.Dimension getPreferredSize(JComponent c)

  If c is the JOptionPane the reciever is contained in, the preferred size that is returned is the maximum of the preferred size of the LayoutManager for the JOptionPane, and `getMinimumOptionPaneSize`.
  Overrides:
    getPreferredSize in class ComponentUI

### getMinimumSize

    public java.awt.Dimension getMinimumSize(JComponent c)

  Messages getPreferredSize.
  Overrides:
    getMinimumSize in class ComponentUI

### getMaximumSize

    public java.awt.Dimension getMaximumSize(JComponent c)

  Messages getPreferredSize.
  Overrides:
    getMaximumSize in class ComponentUI

### createMessageArea

    protected java.awt.Container createMessageArea()

  Messaged from installComponents to create a Container containing the body of the message. The icon is the created by calling `addIcon`.

### addMessageComponents

    protected void addMessageComponents(java.awt.Container container,
                                        java.awt.GridBagConstraints cons,
                                        java.lang.Object msg,
                                        int maxll,
                                        boolean internallyCreated)

  Creates the appropriate object to represent `msg` and places it into `container`. If `msg` is an instance of Component, it is added directly, if it is an Icon, a JLabel is created to represent it, otherwise a JLabel is created for the string, if `d` is an Object[], this method will be recursively invoked for the children. `internallyCreated` is true if Objc is an instance of Component and was created internally by this method (this is used to correctly set hasCustomComponents only if !internallyCreated).

### getMessage

    protected java.lang.Object getMessage()

  Returns the message to display from the JOptionPane the receiver is providing the look and feel for.

### addIcon

    protected void addIcon(java.awt.Container top)

  Creates and adds a JLabel representing the icon returned from `getIcon` to `top`. This is messaged from `createMessageArea`

### getIcon

    protected Icon getIcon()

  Returns the icon from the JOptionPane the reciever is providing the look and feel for, or the default icon as returned from getDefaultIcon.

### getIconForType

    protected Icon getIconForType(int messageType)

  Returns the icon to use for the passed in type.

### getMaxCharactersPerLineCount

    protected int getMaxCharactersPerLineCount()

  Returns the maximum number of characters to place on a line.

### burstStringInto

    protected void burstStringInto(java.awt.Container c,
                                   java.lang.String d,
                                   int maxll)

  Recursively creates new JLabel instances to represent `d`. Each JLabel instance is added to `c`.

### createSeparator

    protected java.awt.Container createSeparator()

### createButtonArea

    protected java.awt.Container createButtonArea()

  Creates and returns a Container containin the buttons. The buttons are created by calling `getButtons`.

### addButtonComponents

    protected void addButtonComponents(java.awt.Container container,
                                       java.lang.Object[] buttons,
                                       int initialIndex)

  Creates the appropriate object to represent each of the objects in `buttons` and adds it to `container`. This differs from addMessageComponents in that it will recurse on `buttons` and that if button is not a Component it will create an instance of JButton.

### createButtonActionListener

    protected java.awt.event.ActionListener createButtonActionListener(int buttonIndex)

### getButtons

    protected java.lang.Object[] getButtons()

  Returns the buttons to display from the JOptionPane the receiver is providing the look and feel for. If the JOptionPane has options set, they will be provided, otherwise if the optionType is YES_NO_OPTION, yesNoOptions is returned, if the type is YES_NO_CANCEL_OPTION yesNoCancelOptions is returned, otherwise defaultButtons are returned.

### getSizeButtonsToSameWidth

    protected boolean getSizeButtonsToSameWidth()

  Returns true, basic L&F wants all the buttons to have the same width.

### getInitialValueIndex

    protected int getInitialValueIndex()

  Returns the initial index into the buttons to select. The index is calculated from the initial value from the JOptionPane and options of the JOptionPane or 0.

### resetInputValue

    protected void resetInputValue()

  Sets the input value in the option pane the receiver is providing the look and feel for based on the value in the inputComponent.

### selectInitialValue

    public void selectInitialValue(JOptionPane op)

  If inputComponent is non-null, the focus is requested on that, otherwise request focus on the default value
  Overrides:
    selectInitialValue in class OptionPaneUI

### containsCustomComponents

    public boolean containsCustomComponents(JOptionPane op)

  Returns true if in the last call to validateComponent the message or buttons contained a subclass of Component.
  Overrides:
    containsCustomComponents in class OptionPaneUI

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.