javax.swing.plaf.metal
Class MetalToggleButtonUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.ButtonUI
          extended by javax.swing.plaf.basic.BasicButtonUI
              extended by javax.swing.plaf.basic.BasicToggleButtonUI
                  extended by javax.swing.plaf.metal.MetalToggleButtonUI

public class MetalToggleButtonUI
extends BasicToggleButtonUI

A UI delegate for the JToggleButton component.


Field Summary
protected  Color disabledTextColor
          The color for disabled button labels.
protected  Color focusColor
          The color for the focus border.
protected  Color selectColor
          The color that indicates a selected button.
 
Fields inherited from class javax.swing.plaf.basic.BasicButtonUI
defaultTextIconGap, defaultTextShiftOffset
 
Constructor Summary
MetalToggleButtonUI()
          Constructs a new instance of MetalToggleButtonUI.
 
Method Summary
static ComponentUI createUI(JComponent component)
          Returns a new instance of MetalToggleButtonUI.
protected  Color getDisabledTextColor()
          Returns the color for the text label of disabled buttons.
protected  Color getFocusColor()
          Returns the color for the focus border.
protected  Color getSelectColor()
          Returns the color that indicates a selected button.
 void installDefaults(AbstractButton b)
          Updates the button with the defaults for this look and feel.
protected  void paintButtonPressed(Graphics g, AbstractButton b)
          Paints the button background when it is pressed/selected.
protected  void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect)
          Draws the focus highlight around the text and icon.
protected  void paintText(Graphics g, JComponent c, Rectangle textRect, String text)
          Paints the text for the button.
 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.
 
Methods inherited from class javax.swing.plaf.basic.BasicToggleButtonUI
getPropertyPrefix, paint, paintIcon
 
Methods inherited from class javax.swing.plaf.basic.BasicButtonUI
clearTextShiftOffset, createButtonListener, getDefaultTextIconGap, getMaximumSize, getMinimumSize, getPreferredSize, getTextShiftOffset, installKeyboardActions, installListeners, installUI, paintIcon, paintText, setTextShiftOffset, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

focusColor

protected Color focusColor
The color for the focus border.


selectColor

protected Color selectColor
The color that indicates a selected button.


disabledTextColor

protected Color disabledTextColor
The color for disabled button labels.

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.

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

getDisabledTextColor

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

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

installDefaults

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

Overrides:
installDefaults in class BasicButtonUI
Parameters:
b - the button.

paintButtonPressed

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

Overrides:
paintButtonPressed in class BasicButtonUI
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 BasicButtonUI.paintText(java.awt.Graphics, javax.swing.AbstractButton, java.awt.Rectangle, java.lang.String).

Overrides:
paintText in class BasicButtonUI
Parameters:
g - the graphics device.
c - the component.
textRect - the bounds for the text.
text - the text.

paintFocus

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

Overrides:
paintFocus in class BasicButtonUI
Parameters:
g - the graphics device.
b - the button.
viewRect - Visible rectangle, the area in which to paint
textRect - Text rectangle, contained in visible rectangle
iconRect - Icon rectangle, contained in visible rectangle
See Also:
AbstractButton.isFocusPainted(), Component.hasFocus()

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.

Overrides:
update in class ComponentUI
Parameters:
g - the graphics for painting.
c - the component for which this delegate performs services.
See Also:
ComponentUI.paint(java.awt.Graphics, javax.swing.JComponent), JComponent.paintComponent(java.awt.Graphics)