APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.basic

public Class BasicOptionPaneUI

extends OptionPaneUI
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.synth.SynthOptionPaneUI, com.sun.java.swing.plaf.motif.MotifOptionPaneUI
Imports
sun.swing.DefaultLookup, .UIAction, javax.swing.border.Border, .EmptyBorder, javax.swing.*, javax.swing.event.*, javax.swing.plaf.ActionMapUIResource, .ComponentUI, .OptionPaneUI, java.awt.*, java.awt.event.*, java.beans.PropertyChangeEvent, .PropertyChangeListener, java.util.Locale

Provides the basic look and feel for a JOptionPane. BasicMessagePaneUI provides a means to place an icon, message and buttons into a Container. Generally, the layout will look like:
       ------------------
       | i | message    |
       | c | message    |
       | o | message    |
       | n | message    |
       ------------------
       |     buttons    |
       |________________|
icon is an instance of Icon that is wrapped 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 above layout is used when the option pane's ComponentOrientation property is horizontal, left-to-right. The layout will be adjusted appropriately for other orientations.

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

Authors
James Gosling, Scott Violet, Amy Fowler

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
BasicOptionPaneUI.Actions

Registered in the ActionMap.

public class
BasicOptionPaneUI.ButtonActionListener

This class should be treated as a "protected" inner class.

public static class
BasicOptionPaneUI.ButtonAreaLayout

ButtonAreaLayout behaves in a similar manner to FlowLayout.

private static class
BasicOptionPaneUI.ButtonFactory

This class is used to create the default buttons.

private class
private static class
BasicOptionPaneUI.MultiplexingTextField

A JTextField that allows you to specify an array of KeyStrokes that that will have their bindings processed regardless of whether or not they are registered on the JTextField.

public class
BasicOptionPaneUI.PropertyChangeHandler

This class should be treated as a "protected" inner class.

Field Summary

Modifier and TypeField and Description
private BasicOptionPaneUI.Handler
protected boolean
hasCustomComponents

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

protected Component
initialFocusComponent

Component to receive focus when messaged with selectInitialValue.

protected JComponent
inputComponent

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

public static final int
MinimumHeight

The minimum height of JOptionPane.

protected Dimension
minimumSize

The size of JOptionPane.

public static final int
MinimumWidth

The minimum width of JOptionPane.

private static String
protected JOptionPane
optionPane

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

protected PropertyChangeListener
propertyChangeListener

The instance of PropertyChangeListener.

private static int

Constructor Summary

AccessConstructor and Description
public
BasicOptionPaneUI()

Constructs a BasicOptionPaneUI.

Method Summary

Modifier and TypeMethod and Description
protected void
addButtonComponents(Container
a container
container
,
Object[]
an array of buttons
buttons
,
int
an initial index
initialIndex
)

Creates the appropriate object to represent each of the objects in buttons and adds it to container.

protected void
addIcon(Container
a container
top
)

Creates and adds a JLabel representing the icon returned from getIcon to top.

protected void
addMessageComponents(Container
a container
container
,
GridBagConstraints
an instance of GridBagConstraints
cons
,
Object
a message
msg
,
int
a maximum length
maxll
,
boolean
true if the component was internally created
internallyCreated
)

Creates the appropriate object to represent msg and places it into container.

protected void
burstStringInto(Container
a container
c
,
String
a text
d
,
int
a maximum length of a text
maxll
)

Recursively creates new JLabel instances to represent d.

private void
configureButton(JButton button)

Configures any necessary colors/fonts for the specified button used representing the button portion of the optionpane.

private void
configureMessageLabel(JLabel label)

Configures any necessary colors/fonts for the specified label used representing the message.

public boolean
containsCustomComponents(JOptionPane op)

Implements abstract javax.swing.plaf.OptionPaneUI.containsCustomComponents.

Returns true if in the last call to validateComponent the message or buttons contained a subclass of Component.

protected ActionListener

Returns:

a new instance of a ButtonActionListener
createButtonActionListener
(int
an index of the button
buttonIndex
)

Constructs a new instance of a ButtonActionListener.

protected Container

Returns:

a Container containing the buttons
createButtonArea
()

Creates and returns a Container containing the buttons.

protected LayoutManager

Returns:

a layout manager
createLayoutManager
()

Returns a layout manager.

protected Container

Returns:

a instance of Container
createMessageArea
()

Messaged from installComponents to create a Container containing the body of the message.

protected PropertyChangeListener

Returns:

an instance of PropertyChangeListener
createPropertyChangeListener
()

Returns an instance of PropertyChangeListener.

protected Container

Returns:

a separator
createSeparator
()

Returns a separator.

public static ComponentUI

Returns:

a new BasicOptionPaneUI instance
createUI
(JComponent
the component
x
)

Hides javax.swing.plaf.ComponentUI.createUI.

Creates a new BasicOptionPaneUI instance.

protected Object[]

Returns:

the buttons to display from the JOptionPane
getButtons
()

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

private BasicOptionPaneUI.Handler
protected Icon

Returns:

the icon
getIcon
()

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

protected Icon

Returns:

the icon to use for the passed in type
getIconForType
(int
a type of message
messageType
)

Returns the icon to use for the passed in type.

protected int

Returns:

the initial index into the buttons to select
getInitialValueIndex
()

Returns the initial index into the buttons to select.

pack-priv InputMap
getInputMap(int condition)

protected int

Returns:

the maximum number of characters to place on a line
getMaxCharactersPerLineCount
()

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

protected Object

Returns:

the message to display
getMessage
()

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

public Dimension

Returns:

the minimum size of the option pane
getMinimumOptionPaneSize
()

Returns the minimum size the option pane should be.

private int
public Dimension
getPreferredSize(JComponent c)

Overrides javax.swing.plaf.ComponentUI.getPreferredSize.

If c is the JOptionPane the receiver 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

Returns:

true if all the buttons should have the same width
getSizeButtonsToSameWidth
()

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

protected void
installComponents()

Registers components.

protected void
installDefaults()

Installs default properties.

protected void
installKeyboardActions()

Registers keyboard actions.

protected void
installListeners()

Registers listeners.

public void
installUI(JComponent c)

Overrides javax.swing.plaf.ComponentUI.installUI.

Installs the receiver as the L&F for the passed in JOptionPane.

pack-priv static void
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.

public void
selectInitialValue(JOptionPane op)

Implements abstract javax.swing.plaf.OptionPaneUI.selectInitialValue.

If inputComponent is non-null, the focus is requested on that, otherwise request focus on the default value

protected void
uninstallComponents()

Unregisters components.

protected void
uninstallDefaults()

Uninstalls default properties.

protected void
uninstallKeyboardActions()

Unregisters keyboard actions.

protected void
uninstallListeners()

Unregisters listeners.

public void
uninstallUI(JComponent c)

Overrides javax.swing.plaf.ComponentUI.uninstallUI.

Removes the receiver from the L&F controller of the passed in split pane.