javax.swing.plaf.metal

Class MetalToggleButtonUI

public class MetalToggleButtonUI extends BasicToggleButtonUI

A UI delegate for the {@link JToggleButton} component.
Field Summary
protected ColordisabledTextColor
The color for disabled button labels.
protected ColorfocusColor
The color for the focus border.
protected ColorselectColor
The color that indicates a selected button.
Constructor Summary
MetalToggleButtonUI()
Constructs a new instance of MetalToggleButtonUI.
Method Summary
static ComponentUIcreateUI(JComponent component)
Returns a new instance of MetalToggleButtonUI.
protected ColorgetDisabledTextColor()
Returns the color for the text label of disabled buttons.
protected ColorgetFocusColor()
Returns the color for the focus border.
protected ColorgetSelectColor()
Returns the color that indicates a selected button.
voidinstallDefaults(AbstractButton b)
Updates the button with the defaults for this look and feel.
protected voidpaintButtonPressed(Graphics g, AbstractButton b)
Paints the button background when it is pressed/selected.
protected voidpaintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect)
Draws the focus highlight around the text and icon.
protected voidpaintText(Graphics g, JComponent c, Rectangle textRect, String text)
Paints the text for the button.
voidupdate(Graphics g, JComponent c)
If the property ToggleButton.gradient is set, then a gradient is painted as background, otherwise the normal superclass behaviour is called.

Field Detail

disabledTextColor

protected Color disabledTextColor
The color for disabled button labels.

focusColor

protected Color focusColor
The color for the focus border.

selectColor

protected Color selectColor
The color that indicates a selected button.

Constructor Detail

MetalToggleButtonUI

public MetalToggleButtonUI()
Constructs a new instance of MetalToggleButtonUI.

Method Detail

createUI

public static ComponentUI createUI(JComponent component)
Returns a new instance of MetalToggleButtonUI.

Parameters: component the component for which we return an UI instance

Returns: A new instance of MetalToggleButtonUI.

getDisabledTextColor

protected Color getDisabledTextColor()
Returns the color for the text label of disabled buttons. The value is initialised in the {@link #installDefaults(AbstractButton)} method by reading the ToggleButton.disabledText item from the UI defaults.

Returns: The color for the text label of disabled buttons.

getFocusColor

protected Color getFocusColor()
Returns the color for the focus border.

Returns: the color for the focus border

getSelectColor

protected Color getSelectColor()
Returns the color that indicates a selected button.

Returns: the color that indicates a selected button

installDefaults

public void installDefaults(AbstractButton b)
Updates the button with the defaults for this look and feel.

Parameters: b the button.

paintButtonPressed

protected void paintButtonPressed(Graphics g, AbstractButton b)
Paints the button background when it is pressed/selected.

Parameters: g the graphics device. b the button.

paintFocus

protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect)
Draws the focus highlight around the text and icon.

Parameters: g the graphics device. b the button.

paintText

protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text)
Paints the text for the button. As of JDK 1.4 this method is obsolete. Use {@link BasicButtonUI#paintText(java.awt.Graphics, javax.swing.AbstractButton, java.awt.Rectangle, java.lang.String)}.

Parameters: g the graphics device. c the component. textRect the bounds for the text. text the text.

update

public void update(Graphics g, JComponent c)
If the property ToggleButton.gradient is set, then a gradient is painted as background, otherwise the normal superclass behaviour is called.