|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.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.
| Field Summary | |
static String |
SET_PAINTABLE
Bound property name for set paintable. |
| 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.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. |
Point |
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()
Sets the component location and size using the information in the given paintable and then refreshes the component by repacking the parent window. |
void |
refreshComponent()
Refreshes the component by repacking the parent window. |
void |
setAction(Action a)
Overrides the inherited method to make sure that the icon for the button is the one associated with the paintable and the text for the button is null. |
void |
setPaintable(Paintable paintable)
Sets the encapsulated paintable to the given paintable and refreshes the screen provided the button is installed in a GUI. |
| 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
| 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.
Ignores the given action if it is null.
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 action if it is null.
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 action if it is null.
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 behaviorcolor - 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 provided the button is installed in a GUI.
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 a)
Overrides the inherited method to make sure that the icon for the
button is the one associated with the paintable and the text for the
button is null.
setAction in class AbstractButtonpublic 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 Point 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.
getPreferredSize in class JComponentpublic Dimension getMinimumSize()
Returns the same dimension as getPreferredSize.
getMinimumSize in class JComponentpublic Dimension getMaximumSize()
Returns the same dimension as getPreferredSize.
getMaximumSize in class JComponentpublic Dimension getSize()
Returns the same dimension as getPreferredSize.
getSize in class Componentpublic void refresh()
Sets the component location and size using the information in the given paintable and then refreshes the component by repacking the parent window.
public void refreshComponent()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||