edu.cmu.hcii.calo.view.FlatButton Class Reference

List of all members.

Detailed Description

A transparent button that appears flat with no border until it is moused over, when a border appears around it.

The border becomes darker when the button is clicked. Flat buttons also subtly lighten their backgrounds when hovered over or clicked.

Author:
Brian Ellis


Public Member Functions

 FlatButton ()
 Constructs a FlatButton.
 FlatButton (Action a)
 Constructs a FlatButton with the given action.
 FlatButton (Icon icon)
 Constructs a FlatButton with the given icon.
 FlatButton (String text)
 Constructs a FlatButton with the given label.
 FlatButton (String text, Icon icon)
 Constructs a FlatButton with the given label and icon.
void setPadding (int horizontalPadding, int verticalPadding)
 Sets the "padding" of the button, which is the space that will be left between the edge of the label (and icon, if applicable) and the edge of the button.
Color getBackground ()
 Returns the base (effective) background color of this button.
void setBackground (Color bg)
 Sets the base (effective) background color of this button to the given color, which may use an alpha channel for transparency.

Protected Member Functions

void paintComponent (Graphics g)
 Paints this button.

Protected Attributes

Borders
Border styles for the FlatButton.

Border pressedBorder
 The pressed border style.
Border mouseoverBorder
 The mouseover border style.
Border normalBorder
 The normal border style.

Private Member Functions

void setup ()
 Sets up the visual appearance of this button.
void updateAppearance ()
 Causes this button to update its appearance.

Private Attributes

boolean isMouseDown
 Whether the mouse is currently being held down after having been pressed inside this button.
boolean isMouseOver
 Whether the mouse is currently hovering over this button.
Colors
Colors used when drawing the button.

Color backgroundOverlay
 The color that is lain over the effective background color.
Color effectiveBackground
 The base color of this button.

Static Private Attributes

static final long serialVersionUID = 1L
 Prevent serialization collisions.


Constructor & Destructor Documentation

edu.cmu.hcii.calo.view.FlatButton.FlatButton (  ) 

Constructs a FlatButton.

edu.cmu.hcii.calo.view.FlatButton.FlatButton ( Action  a  ) 

Constructs a FlatButton with the given action.

Parameters:
a the action

edu.cmu.hcii.calo.view.FlatButton.FlatButton ( Icon  icon  ) 

Constructs a FlatButton with the given icon.

Parameters:
icon the icon

edu.cmu.hcii.calo.view.FlatButton.FlatButton ( String  text  ) 

Constructs a FlatButton with the given label.

Parameters:
text the label

edu.cmu.hcii.calo.view.FlatButton.FlatButton ( String  text,
Icon  icon 
)

Constructs a FlatButton with the given label and icon.

Parameters:
text the label
icon the icon


Member Function Documentation

void edu.cmu.hcii.calo.view.FlatButton.setPadding ( int  horizontalPadding,
int  verticalPadding 
)

Sets the "padding" of the button, which is the space that will be left between the edge of the label (and icon, if applicable) and the edge of the button.

The same padding is always used for left and right, and for top and bottom, so the width of the button, for example, will be the width of the label and icon plus twice the horizontal padding.

Parameters:
horizontalPadding the horizontal padding
verticalPadding the vertical padding

void edu.cmu.hcii.calo.view.FlatButton.setup (  )  [private]

Sets up the visual appearance of this button.

void edu.cmu.hcii.calo.view.FlatButton.updateAppearance (  )  [private]

Causes this button to update its appearance.

This does not repaint the button, it merely sets the state correctly for the next time the button is painted.

Color edu.cmu.hcii.calo.view.FlatButton.getBackground (  ) 

Returns the base (effective) background color of this button.

This will be transparent unless setBackground() has been called with a different color at some point in the past.

See also:
java.awt.Component.getBackground()

void edu.cmu.hcii.calo.view.FlatButton.setBackground ( Color  bg  ) 

Sets the base (effective) background color of this button to the given color, which may use an alpha channel for transparency.

Parameters:
bg the new background color
See also:
javax.swing.JComponent.setBackground(java.awt.Color)

void edu.cmu.hcii.calo.view.FlatButton.paintComponent ( Graphics  g  )  [protected]

Paints this button.

Parameters:
g the graphics context to paint into


Member Data Documentation

final long edu.cmu.hcii.calo.view.FlatButton.serialVersionUID = 1L [static, private]

Prevent serialization collisions.

Border edu.cmu.hcii.calo.view.FlatButton.pressedBorder [protected]

The pressed border style.

Border edu.cmu.hcii.calo.view.FlatButton.mouseoverBorder [protected]

The mouseover border style.

Border edu.cmu.hcii.calo.view.FlatButton.normalBorder [protected]

The normal border style.

boolean edu.cmu.hcii.calo.view.FlatButton.isMouseDown [private]

Whether the mouse is currently being held down after having been pressed inside this button.

boolean edu.cmu.hcii.calo.view.FlatButton.isMouseOver [private]

Whether the mouse is currently hovering over this button.

Color edu.cmu.hcii.calo.view.FlatButton.backgroundOverlay [private]

The color that is lain over the effective background color.

Color edu.cmu.hcii.calo.view.FlatButton.effectiveBackground [private]

The base color of this button.

By default the button is transparent.


The documentation for this class was generated from the following file:
Generated on Mon Aug 13 15:06:22 2007 for CALO by  doxygen 1.5.2