- java.lang.Object
- 
- javax.swing.plaf.ComponentUI
- 
- javax.swing.plaf.OptionPaneUI
- 
- javax.swing.plaf.basic.BasicOptionPaneUI
 
 
 
- 
- Direct Known Subclasses:
- SynthOptionPaneUI
 
 public class BasicOptionPaneUI extends OptionPaneUI Provides the basic look and feel for aJOptionPane.BasicMessagePaneUIprovides a means to place an icon, message and buttons into aContainer. Generally, the layout will look like:------------------ | i | message | | c | message | | o | message | | n | message | ------------------ | buttons | |________________|icon is an instance ofIconthat is wrapped inside aJLabel. The message is an opaque object and is tested for the following: if the message is aComponentit is added to theContainer, if it is anIconit is wrapped inside aJLabeland added to theContainerotherwise it is wrapped inside aJLabel.The above layout is used when the option pane's ComponentOrientationproperty 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.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classBasicOptionPaneUI.ButtonActionListenerThis class should be treated as a "protected" inner class.static classBasicOptionPaneUI.ButtonAreaLayoutButtonAreaLayoutbehaves in a similar manner toFlowLayout.classBasicOptionPaneUI.PropertyChangeHandlerThis class should be treated as a "protected" inner class.
 - 
Field SummaryFields Modifier and Type Field Description protected booleanhasCustomComponentsThis is set to true in validateComponent if a Component is contained in either the message or the buttons.protected ComponentinitialFocusComponentComponent to receive focus when messaged with selectInitialValue.protected JComponentinputComponentJComponent provide for input if optionPane.getWantsInput() returns true.static intMinimumHeightThe mininum height ofJOptionPane.protected DimensionminimumSizeThe size ofJOptionPane.static intMinimumWidthThe mininum width ofJOptionPane.protected JOptionPaneoptionPaneJOptionPanethat the receiver is providing the look and feel for.protected PropertyChangeListenerpropertyChangeListenerThe instance ofPropertyChangeListener.
 - 
Constructor SummaryConstructors Constructor Description BasicOptionPaneUI()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddButtonComponents(Container container, Object[] buttons, int initialIndex)Creates the appropriate object to represent each of the objects inbuttonsand adds it tocontainer.protected voidaddIcon(Container top)Creates and adds a JLabel representing the icon returned fromgetIcontotop.protected voidaddMessageComponents(Container container, GridBagConstraints cons, Object msg, int maxll, boolean internallyCreated)Creates the appropriate object to representmsgand places it intocontainer.protected voidburstStringInto(Container c, String d, int maxll)Recursively creates newJLabelinstances to representd.booleancontainsCustomComponents(JOptionPane op)Returns true if in the last call to validateComponent the message or buttons contained a subclass of Component.protected ActionListenercreateButtonActionListener(int buttonIndex)Constructs a new instance of aButtonActionListener.protected ContainercreateButtonArea()Creates and returns aContainercontaining the buttons.protected LayoutManagercreateLayoutManager()Returns a layout manager.protected ContainercreateMessageArea()Messaged frominstallComponentsto create aContainercontaining the body of the message.protected PropertyChangeListenercreatePropertyChangeListener()Returns an instance ofPropertyChangeListener.protected ContainercreateSeparator()Returns a separator.static ComponentUIcreateUI(JComponent x)Creates a newBasicOptionPaneUIinstance.protected Object[]getButtons()Returns the buttons to display from theJOptionPanethe receiver is providing the look and feel for.protected IcongetIcon()Returns the icon from theJOptionPanethe receiver is providing the look and feel for, or the default icon as returned fromgetDefaultIcon.protected IcongetIconForType(int messageType)Returns the icon to use for the passed in type.protected intgetInitialValueIndex()Returns the initial index into the buttons to select.protected intgetMaxCharactersPerLineCount()Returns the maximum number of characters to place on a line.protected ObjectgetMessage()Returns the message to display from theJOptionPanethe receiver is providing the look and feel for.DimensiongetMinimumOptionPaneSize()Returns the minimum size the option pane should be.DimensiongetPreferredSize(JComponent c)Ifcis theJOptionPanethe receiver is contained in, the preferred size that is returned is the maximum of the preferred size of theLayoutManagerfor theJOptionPane, andgetMinimumOptionPaneSize.protected booleangetSizeButtonsToSameWidth()Returnstrue, basic L&F wants all the buttons to have the same width.protected voidinstallComponents()Registers components.protected voidinstallDefaults()Installs default properties.protected voidinstallKeyboardActions()Registers keyboard actions.protected voidinstallListeners()Registers listeners.voidinstallUI(JComponent c)Installs the receiver as the L&F for the passed inJOptionPane.protected voidresetInputValue()Sets the input value in the option pane the receiver is providing the look and feel for based on the value in the inputComponent.voidselectInitialValue(JOptionPane op)If inputComponent is non-null, the focus is requested on that, otherwise request focus on the default valueprotected voiduninstallComponents()Unregisters components.protected voiduninstallDefaults()Uninstalls default properties.protected voiduninstallKeyboardActions()Unregisters keyboard actions.protected voiduninstallListeners()Unregisters listeners.voiduninstallUI(JComponent c)Removes the receiver from the L&F controller of the passed in split pane.- 
Methods declared in class javax.swing.plaf.ComponentUIcontains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, paint, update
 
- 
 
- 
- 
- 
Field Detail- 
MinimumWidthpublic static final int MinimumWidth The mininum width ofJOptionPane.- See Also:
- Constant Field Values
 
 - 
MinimumHeightpublic static final int MinimumHeight The mininum height ofJOptionPane.- See Also:
- Constant Field Values
 
 - 
optionPaneprotected JOptionPane optionPane JOptionPanethat the receiver is providing the look and feel for.
 - 
minimumSizeprotected Dimension minimumSize The size ofJOptionPane.
 - 
inputComponentprotected JComponent inputComponent JComponent provide for input if optionPane.getWantsInput() returns true.
 - 
initialFocusComponentprotected Component initialFocusComponent Component to receive focus when messaged with selectInitialValue.
 - 
hasCustomComponentsprotected boolean hasCustomComponents This is set to true in validateComponent if a Component is contained in either the message or the buttons.
 - 
propertyChangeListenerprotected PropertyChangeListener propertyChangeListener The instance ofPropertyChangeListener.
 
- 
 - 
Method Detail- 
createUIpublic static ComponentUI createUI(JComponent x) Creates a newBasicOptionPaneUIinstance.- Parameters:
- x- the component
- Returns:
- a new BasicOptionPaneUIinstance
 
 - 
installUIpublic void installUI(JComponent c) Installs the receiver as the L&F for the passed inJOptionPane.- Overrides:
- installUIin class- ComponentUI
- Parameters:
- c- the component where this UI delegate is being installed
- See Also:
- ComponentUI.uninstallUI(javax.swing.JComponent),- JComponent.setUI(javax.swing.plaf.ComponentUI),- JComponent.updateUI()
 
 - 
uninstallUIpublic void uninstallUI(JComponent c) Removes the receiver from the L&F controller of the passed in split pane.- Overrides:
- uninstallUIin class- ComponentUI
- Parameters:
- c- the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
- See Also:
- ComponentUI.installUI(javax.swing.JComponent),- JComponent.updateUI()
 
 - 
installDefaultsprotected void installDefaults() Installs default properties.
 - 
uninstallDefaultsprotected void uninstallDefaults() Uninstalls default properties.
 - 
installComponentsprotected void installComponents() Registers components.
 - 
uninstallComponentsprotected void uninstallComponents() Unregisters components.
 - 
createLayoutManagerprotected LayoutManager createLayoutManager() Returns a layout manager.- Returns:
- a layout manager
 
 - 
installListenersprotected void installListeners() Registers listeners.
 - 
uninstallListenersprotected void uninstallListeners() Unregisters listeners.
 - 
createPropertyChangeListenerprotected PropertyChangeListener createPropertyChangeListener() Returns an instance ofPropertyChangeListener.- Returns:
- an instance of PropertyChangeListener
 
 - 
installKeyboardActionsprotected void installKeyboardActions() Registers keyboard actions.
 - 
uninstallKeyboardActionsprotected void uninstallKeyboardActions() Unregisters keyboard actions.
 - 
getMinimumOptionPaneSizepublic Dimension getMinimumOptionPaneSize() Returns the minimum size the option pane should be. Primarily provided for subclassers wishing to offer a different minimum size.- Returns:
- the minimum size of the option pane
 
 - 
getPreferredSizepublic Dimension getPreferredSize(JComponent c) Ifcis theJOptionPanethe receiver is contained in, the preferred size that is returned is the maximum of the preferred size of theLayoutManagerfor theJOptionPane, andgetMinimumOptionPaneSize.- Overrides:
- getPreferredSizein class- ComponentUI
- Parameters:
- c- the component whose preferred size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
- Returns:
- a Dimensionobject containing given component's preferred size appropriate for the look and feel
- See Also:
- JComponent.getPreferredSize(),- LayoutManager.preferredLayoutSize(java.awt.Container)
 
 - 
createMessageAreaprotected Container createMessageArea() Messaged frominstallComponentsto create aContainercontaining the body of the message. The icon is the created by callingaddIcon.- Returns:
- a instance of Container
 
 - 
addMessageComponentsprotected void addMessageComponents(Container container, GridBagConstraints cons, Object msg, int maxll, boolean internallyCreated) Creates the appropriate object to representmsgand places it intocontainer. Ifmsgis an instance ofComponent, it is added directly; if it is anIcon, aJLabelis created to represent it; otherwise, aJLabelis created for the string. Ifmsgis an Object[], this method will be recursively invoked for the children.internallyCreatedistrueifmsgis an instance ofComponentand was created internally by this method (this is used to correctly sethasCustomComponentsonly ifinternallyCreatedisfalse).- Parameters:
- container- a container
- cons- an instance of- GridBagConstraints
- msg- a message
- maxll- a maximum length
- internallyCreated-- trueif the component was internally created
 
 - 
getMessageprotected Object getMessage() Returns the message to display from theJOptionPanethe receiver is providing the look and feel for.- Returns:
- the message to display
 
 - 
addIconprotected void addIcon(Container top) Creates and adds a JLabel representing the icon returned fromgetIcontotop. This is messaged fromcreateMessageArea.- Parameters:
- top- a container
 
 - 
getIconprotected Icon getIcon() Returns the icon from theJOptionPanethe receiver is providing the look and feel for, or the default icon as returned fromgetDefaultIcon.- Returns:
- the icon
 
 - 
getIconForTypeprotected Icon getIconForType(int messageType) Returns the icon to use for the passed in type.- Parameters:
- messageType- a type of message
- Returns:
- the icon to use for the passed in type
 
 - 
getMaxCharactersPerLineCountprotected int getMaxCharactersPerLineCount() Returns the maximum number of characters to place on a line.- Returns:
- the maximum number of characters to place on a line
 
 - 
burstStringIntoprotected void burstStringInto(Container c, String d, int maxll) Recursively creates newJLabelinstances to representd. EachJLabelinstance is added toc.- Parameters:
- c- a container
- d- a text
- maxll- a maximum length of a text
 
 - 
createSeparatorprotected Container createSeparator() Returns a separator.- Returns:
- a separator
 
 - 
createButtonAreaprotected Container createButtonArea() Creates and returns aContainercontaining the buttons. The buttons are created by callinggetButtons.- Returns:
- a Containercontaining the buttons
 
 - 
addButtonComponentsprotected void addButtonComponents(Container container, Object[] buttons, int initialIndex) Creates the appropriate object to represent each of the objects inbuttonsand adds it tocontainer. This differs from addMessageComponents in that it will recurse onbuttonsand that if button is not a Component it will create an instance of JButton.- Parameters:
- container- a container
- buttons- an array of buttons
- initialIndex- an initial index
 
 - 
createButtonActionListenerprotected ActionListener createButtonActionListener(int buttonIndex) Constructs a new instance of aButtonActionListener.- Parameters:
- buttonIndex- an index of the button
- Returns:
- a new instance of a ButtonActionListener
 
 - 
getButtonsprotected Object[] getButtons() Returns the buttons to display from theJOptionPanethe receiver is providing the look and feel for. If theJOptionPanehas options set, they will be provided, otherwise if the optionType isYES_NO_OPTION,yesNoOptionsis returned, if the type isYES_NO_CANCEL_OPTIONyesNoCancelOptionsis returned, otherwisedefaultButtonsare returned.- Returns:
- the buttons to display from the JOptionPane
 
 - 
getSizeButtonsToSameWidthprotected boolean getSizeButtonsToSameWidth() Returnstrue, basic L&F wants all the buttons to have the same width.- Returns:
- trueif all the buttons should have the same width
 
 - 
getInitialValueIndexprotected 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.- Returns:
- the initial index into the buttons to select
 
 - 
resetInputValueprotected 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.
 - 
selectInitialValuepublic void selectInitialValue(JOptionPane op) If inputComponent is non-null, the focus is requested on that, otherwise request focus on the default value- Specified by:
- selectInitialValuein class- OptionPaneUI
- Parameters:
- op- a- JOptionPane
 
 - 
containsCustomComponentspublic boolean containsCustomComponents(JOptionPane op) Returns true if in the last call to validateComponent the message or buttons contained a subclass of Component.- Specified by:
- containsCustomComponentsin class- OptionPaneUI
- Parameters:
- op- a- JOptionPane
- Returns:
- trueif the given- JOptionPanecontains user created- Components
 
 
- 
 
-