javax.swing.plaf.metal
Class MetalButtonUI

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.metal.MetalButtonUI

public class MetalButtonUI
extends BasicButtonUI

A UI delegate for the JButton component.


Field Summary
protected  Color disabledTextColor
          The color for disabled button labels.
protected  Color focusColor
          The color used to draw the focus rectangle around the text and/or icon.
protected  Color selectColor
          The background color for the button when it is pressed.
 
Fields inherited from class javax.swing.plaf.basic.BasicButtonUI
defaultTextIconGap, defaultTextShiftOffset
 
Constructor Summary
MetalButtonUI()
          Creates a new instance.
 
Method Summary
static ComponentUI createUI(JComponent c)
          Returns a UI delegate for the specified component.
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 button)
          Installs the default settings for the specified button.
protected  void paintButtonPressed(Graphics g, AbstractButton b)
          Paints the background of the button to indicate that it is in the "pressed" state.
protected  void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect)
          Paints the focus rectangle around the button text and/or icon.
protected  void paintText(Graphics g, JComponent c, Rectangle textRect, String text)
          Paints the button text.
 void uninstallDefaults(AbstractButton button)
          Removes the defaults added by installDefaults(AbstractButton).
 void update(Graphics g, JComponent c)
          If the property Button.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.BasicButtonUI
clearTextShiftOffset, createButtonListener, getDefaultTextIconGap, getMaximumSize, getMinimumSize, getPreferredSize, getPropertyPrefix, getTextShiftOffset, installKeyboardActions, installListeners, installUI, paint, paintIcon, paintText, setTextShiftOffset, 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 used to draw the focus rectangle around the text and/or icon.


selectColor

protected Color selectColor
The background color for the button when it is pressed.


disabledTextColor

protected Color disabledTextColor
The color for disabled button labels.

Constructor Detail

MetalButtonUI

public MetalButtonUI()
Creates a new instance.

Method Detail

createUI

public static ComponentUI createUI(JComponent c)
Returns a UI delegate for the specified component.

Parameters:
c - the component (should be a subclass of AbstractButton).
Returns:
A new instance of MetalButtonUI.

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.

Returns:
the color for the text label of disabled buttons

installDefaults

public void installDefaults(AbstractButton button)
Installs the default settings for the specified button.

Overrides:
installDefaults in class BasicButtonUI
Parameters:
button - the button.
See Also:
uninstallDefaults(AbstractButton)

uninstallDefaults

public void uninstallDefaults(AbstractButton button)
Removes the defaults added by installDefaults(AbstractButton).

Overrides:
uninstallDefaults in class BasicButtonUI
Parameters:
button - the button (null not permitted).

paintButtonPressed

protected void paintButtonPressed(Graphics g,
                                  AbstractButton b)
Paints the background of the button to indicate that it is in the "pressed" state.

Overrides:
paintButtonPressed in class BasicButtonUI
Parameters:
g - the graphics context.
b - the button.

paintFocus

protected void paintFocus(Graphics g,
                          AbstractButton b,
                          Rectangle viewRect,
                          Rectangle textRect,
                          Rectangle iconRect)
Paints the focus rectangle around the button text and/or icon.

Overrides:
paintFocus in class BasicButtonUI
Parameters:
g - the graphics context.
b - the button.
viewRect - the button bounds.
textRect - the text bounds.
iconRect - the icon bounds.
See Also:
AbstractButton.isFocusPainted(), Component.hasFocus()

paintText

protected void paintText(Graphics g,
                         JComponent c,
                         Rectangle textRect,
                         String text)
Paints the button text.

Overrides:
paintText in class BasicButtonUI
Parameters:
g - the graphics context.
c - the button.
textRect - the text bounds.
text - the text to display.

update

public void update(Graphics g,
                   JComponent c)
If the property Button.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)