The border becomes darker when the button is clicked. Flat buttons also subtly lighten their backgrounds when hovered over or clicked.
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. |
edu.cmu.hcii.calo.view.FlatButton.FlatButton | ( | ) |
Constructs a FlatButton.
edu.cmu.hcii.calo.view.FlatButton.FlatButton | ( | Action | a | ) |
edu.cmu.hcii.calo.view.FlatButton.FlatButton | ( | Icon | icon | ) |
edu.cmu.hcii.calo.view.FlatButton.FlatButton | ( | String | text | ) |
edu.cmu.hcii.calo.view.FlatButton.FlatButton | ( | String | text, | |
Icon | icon | |||
) |
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.
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.
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.
bg | the new background color |
void edu.cmu.hcii.calo.view.FlatButton.paintComponent | ( | Graphics | g | ) | [protected] |
Paints this button.
g | the graphics context to paint into |
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.