|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JButton
edu.neu.ccs.gui.PaintableButton
Class PaintableButton encapsulates a
Paintable and uses that paintable to define the
icon for the button and to determine the size of the button.
As of 2.5.0, the built-in listener that listens for changes to the paintable or button will normally repaint() but will do a full refresh() if it detects that the bounds of the internal paintable have changed.
| Nested Class Summary | |
private class |
PaintableButton.RefreshListener
The internal refresh listener class. |
| Nested classes inherited from class javax.swing.JButton |
JButton.AccessibleJButton |
| Nested classes inherited from class javax.swing.AbstractButton |
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener |
| Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
private Rectangle2D |
bounds
The current default bounds of the component. |
private PaintableComponent |
component
The paintable component associated with the paintable. |
private static Insets |
DEFAULT_INSETS
The default button insets if not provided. |
private PaintableButton.RefreshListener |
listener
The internal refresh listener. |
private Paintable |
paintable
The encapsulated paintable that defines this button. |
static String |
SET_PAINTABLE
Bound property name for set paintable. |
| Fields inherited from class javax.swing.JButton |
|
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
PaintableButton(Paintable paintable)
This constructor provides the paintable needed to define the button. |
|
PaintableButton(Paintable paintable,
Action action)
This constructor provides the paintable needed to define the button, and the action for the button behavior. |
|
PaintableButton(Paintable paintable,
Action action,
Color color)
This constructor provides the paintable needed to define the button, the action for the button behavior and the optional background color. |
|
PaintableButton(Paintable paintable,
Action action,
Color color,
Insets insets)
This constructor provides the paintable needed to define the button, the action for the button behavior the optional background color, and the button insets (margin). |
|
| Method Summary | |
Rectangle2D |
getDefaultBounds2D()
Returns the default bounds for the button using the information in the encapsulated paintable and the insets. |
Point2D |
getDefaultLocation()
Returns the default location for the button using the information in the encapsulated paintable and the insets. |
Dimension |
getMaximumSize()
Returns the same dimension as getPreferredSize. |
Dimension |
getMinimumSize()
Returns the same dimension as getPreferredSize. |
Paintable |
getPaintable()
Returns the encapsulated paintable. |
Dimension |
getPreferredSize()
Returns the preferred size of the button based on the bounds of the encapsulated paintable and the button insets. |
Dimension |
getSize()
Returns the same dimension as getPreferredSize. |
void |
refresh()
If the default bounds rectangle of this button has not changed then calls repaint();
otherwise sets the button location and size using the
default bounds rectangle and refreshes the button by
repacking the parent window. |
void |
refreshComponent()
Refreshes the component by repacking the parent window. |
void |
setAction(Action action)
Overrides the inherited method to make sure that the icon for the button is the component associated with the paintable and that the text for the button is null. |
void |
setPaintable(Paintable paintable)
Sets the encapsulated paintable to the given paintable and refreshes the screen. |
| Methods inherited from class javax.swing.JButton |
configurePropertiesFromAction, getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String SET_PAINTABLE
private static final Insets DEFAULT_INSETS
private Paintable paintable
private PaintableComponent component
private Rectangle2D bounds
private PaintableButton.RefreshListener listener
| Constructor Detail |
public PaintableButton(Paintable paintable)
This constructor provides the paintable needed to define the button.
Throws NullPointerException if the given paintable
is null.
The button behavior must be supplied later.
This button uses the default JButton background color.
This button uses default insets of 2, 2, 2, 2 which are not the Java default but which work better with most paintable objects.
paintable - the paintable to encapsulatePaintableButton(Paintable, Action),
PaintableButton(Paintable, Action, Color),
PaintableButton(Paintable, Action, Color, Insets)
public PaintableButton(Paintable paintable,
Action action)
This constructor provides the paintable needed to define the button, and the action for the button behavior.
Throws NullPointerException if the given paintable
is null.
Determines the button icon from the paintable and ignores any NAME or SMALL_ICON properties that may be set for the action.
This button uses the default JButton background color.
This button uses default insets of 2, 2, 2, 2 which are not the Java default but which work better with most paintable objects.
paintable - the paintable to encapsulateaction - the action for the button behaviorPaintableButton(Paintable),
PaintableButton(Paintable, Action, Color),
PaintableButton(Paintable, Action, Color, Insets)
public PaintableButton(Paintable paintable,
Action action,
Color color)
This constructor provides the paintable needed to define the button, the action for the button behavior and the optional background color.
Throws NullPointerException if the given paintable
is null.
Determines the button icon from the paintable and ignores any NAME or SMALL_ICON properties that may be set for the action.
Ignores the given color if it is null.
This button uses default insets of 2, 2, 2, 2 which are not the Java default but which work better with most paintable objects.
paintable - the paintable to encapsulateaction - the action for the button behaviorcolor - the optional background colorPaintableButton(Paintable),
PaintableButton(Paintable, Action),
PaintableButton(Paintable, Action, Color, Insets)
public PaintableButton(Paintable paintable,
Action action,
Color color,
Insets insets)
This constructor provides the paintable needed to define the button, the action for the button behavior the optional background color, and the button insets (margin).
Throws NullPointerException if the given paintable
is null.
Determines the button icon from the paintable and ignores any NAME or SMALL_ICON properties that may be set for the action.
Ignores the given color if it is null.
If the given insets is null, it is set to 2, 2, 2, 2.
paintable - the paintable to encapsulateaction - the action for the button behavior or nullcolor - the optional background colorinsets - the button insets or marginPaintableButton(Paintable),
PaintableButton(Paintable, Action),
PaintableButton(Paintable, Action, Color)| Method Detail |
public void setPaintable(Paintable paintable)
Sets the encapsulated paintable to the given paintable and refreshes the screen.
Does nothing if the given paintable is null
or if it is the same object as the encapsulated paintable.
Fires property change: SET_PAINTABLE.
paintable - the paintable to encapsulatepublic Paintable getPaintable()
Returns the encapsulated paintable.
public void setAction(Action action)
Overrides the inherited method to make sure that the icon
for the button is the component associated with the paintable
and that the text for the button is null.
action - the action for the button behavior or nullpublic Rectangle2D getDefaultBounds2D()
Returns the default bounds for the button using the information in the encapsulated paintable and the insets.
A LayoutManager may change the actual bounds of the button in a GUI to satisfy layout decisions.
public Point2D getDefaultLocation()
Returns the default location for the button using the information in the encapsulated paintable and the insets.
A LayoutManager may change the actual location of the button in a GUI to satisfy layout decisions.
public Dimension getPreferredSize()
Returns the preferred size of the button based on the bounds of the encapsulated paintable and the button insets.
public Dimension getMinimumSize()
Returns the same dimension as getPreferredSize.
public Dimension getMaximumSize()
Returns the same dimension as getPreferredSize.
public Dimension getSize()
Returns the same dimension as getPreferredSize.
public void refresh()
If the default bounds rectangle of this button has
not changed then calls repaint();
otherwise sets the button location and size using the
default bounds rectangle and refreshes the button by
repacking the parent window.
public void refreshComponent()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||