javax.swing.plaf.metal

Class MetalComboBoxButton

public class MetalComboBoxButton extends JButton

A button used by the {@link MetalComboBoxUI} class.
Field Summary
protected JComboBoxcomboBox
A reference to the JComboBox that the button belongs to.
protected IconcomboIcon
The button icon.
protected booleaniconOnly
Display just the icon, or the icon plus the label.
protected JListlistBox
A reference to the JList.
protected CellRendererPanerendererPane
Used for rendering the selected item.
Constructor Summary
MetalComboBoxButton(JComboBox cb, Icon i, CellRendererPane pane, JList list)
Creates a new button.
MetalComboBoxButton(JComboBox cb, Icon i, boolean onlyIcon, CellRendererPane pane, JList list)
Creates a new button.
Method Summary
JComboBoxgetComboBox()
Returns the combo box that the button is used with.
IcongetComboIcon()
Returns the icon displayed by the button.
booleanisFocusTraversable()
Returns false, to indicate that this component is not part of the focus traversal group.
booleanisIconOnly()
Returns a flag that controls whether the button displays an icon only, or text as well.
voidpaintComponent(Graphics g)
Paints the component.
voidsetComboBox(JComboBox cb)
Sets the combo box that the button is used with.
voidsetComboIcon(Icon i)
Sets the icon displayed by the button.
voidsetEnabled(boolean enabled)
Enables or disables the button.
voidsetIconOnly(boolean isIconOnly)
Sets the flag that controls whether the button displays an icon only, or text as well.

Field Detail

comboBox

protected JComboBox comboBox
A reference to the JComboBox that the button belongs to.

comboIcon

protected Icon comboIcon
The button icon.

iconOnly

protected boolean iconOnly
Display just the icon, or the icon plus the label.

listBox

protected JList listBox
A reference to the JList.

rendererPane

protected CellRendererPane rendererPane
Used for rendering the selected item.

Constructor Detail

MetalComboBoxButton

public MetalComboBoxButton(JComboBox cb, Icon i, CellRendererPane pane, JList list)
Creates a new button.

Parameters: cb the combo that the button is used for (null not permitted). i the icon displayed on the button. pane the rendering pane. list the list.

MetalComboBoxButton

public MetalComboBoxButton(JComboBox cb, Icon i, boolean onlyIcon, CellRendererPane pane, JList list)
Creates a new button.

Parameters: cb the combo that the button is used for (null not permitted). i the icon displayed on the button. onlyIcon a flag that specifies whether the button displays only an icon, or text as well. pane the rendering pane. list the list.

Method Detail

getComboBox

public final JComboBox getComboBox()
Returns the combo box that the button is used with.

Returns: The combo box.

getComboIcon

public final Icon getComboIcon()
Returns the icon displayed by the button. By default, this will be an instance of {@link MetalComboBoxIcon}.

Returns: The icon displayed by the button.

isFocusTraversable

public boolean isFocusTraversable()
Returns false, to indicate that this component is not part of the focus traversal group.

Returns: false

isIconOnly

public final boolean isIconOnly()
Returns a flag that controls whether the button displays an icon only, or text as well.

Returns: A boolean.

paintComponent

public void paintComponent(Graphics g)
Paints the component.

Parameters: g the graphics device.

setComboBox

public final void setComboBox(JComboBox cb)
Sets the combo box that the button is used with.

Parameters: cb the combo box.

setComboIcon

public final void setComboIcon(Icon i)
Sets the icon displayed by the button.

Parameters: i the icon.

setEnabled

public void setEnabled(boolean enabled)
Enables or disables the button.

Parameters: enabled the new status.

setIconOnly

public final void setIconOnly(boolean isIconOnly)
Sets the flag that controls whether the button displays an icon only, or text as well.

Parameters: isIconOnly the flag.