|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.awt.Component
|
+--com.rolemodelsoft.drawlet.awt.ColorButton
A button which uses an image instead of a label.
| Field Summary | |
protected java.awt.event.ActionListener |
actionListener
The actionListener member variable, for dispatching events. |
protected java.awt.Color |
color
The image for this button. |
protected java.lang.String |
command
The label (not visible) for this button. |
protected boolean |
isHighlighted
Flag indicating the current value of highlighting. |
protected boolean |
isInside
Flag that is set when the mouse is inside |
protected boolean |
isPressed
Flag that is set when the mouse is pressed inside. |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
| Constructor Summary | |
ColorButton()
Create a new, default ColorButton |
|
ColorButton(java.awt.Color color)
Create a new ColorButton initialized with the given color. |
|
ColorButton(java.lang.String command)
Create a new ColorButton initialized with the given command. |
|
ColorButton(java.lang.String command,
java.awt.Color color)
Create a new ColorButton initialized with the given command and color. |
|
| Method Summary | |
void |
addActionListener(java.awt.event.ActionListener listener)
Add the given ActionListener to my set of listeners. |
java.awt.Color |
getColor()
Answers the Color this button represents and displays. |
java.lang.String |
getCommand()
Answer the command associated with this receiver. |
protected java.awt.Color |
getDefaultColor()
Answers the default color for the receiver (intended for initialization). |
protected java.lang.String |
getDefaultCommand()
Answers the default command for the receiver (intended for initialization). |
java.awt.Dimension |
getMinimumSize()
Answer the size this color button must be displayed at. |
java.awt.Dimension |
getPreferredSize()
Answer the size this color button prefers to be displayed at. |
boolean |
isHighlighted()
Answer whether or not the receiver is to be drawn highlighted. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Mouse events are handled in MousePressed and MouseReleased. |
void |
mouseEntered(java.awt.event.MouseEvent e)
If the mouse moves inside of the button, set the isInside flag. |
void |
mouseExited(java.awt.event.MouseEvent e)
If the mouse moves outside of the button, reset the isInside flag. |
void |
mousePressed(java.awt.event.MouseEvent e)
If the mouse is pressed inside of the button, set the isPressed flag. |
void |
mouseReleased(java.awt.event.MouseEvent e)
If the mouse is released, check to see if it is inside of the button, and if it was originally pressed inside of the button. |
void |
paint(java.awt.Graphics g)
Paint the button. |
void |
paintHighlight(java.awt.Graphics g,
java.awt.Color firstColor,
java.awt.Color secondColor)
Paint the button highlight. |
void |
paintHighlighted(java.awt.Graphics g)
Paint the button highlighted (down). |
void |
paintLabel(java.awt.Graphics g,
int moveBy)
Paint the label form, offsetting it by the given amount. |
void |
paintUnhighlighted(java.awt.Graphics g)
Paint the button unhighlighted (not down). |
void |
processActionEvent()
Create an ActionEvent and pass it to everyone listening for it. |
void |
removeActionListener(java.awt.event.ActionListener listener)
Remove the given ActionListener from my set of listeners. |
void |
setColor(java.awt.Color color)
Set the Color this button is associated with. |
void |
setCommand(java.lang.String command)
Set the command associated with this receiver. |
void |
setHighlighted(boolean highlighted)
Set whether or not the receiver is to be drawn highlighted. |
| Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addNotify,
addPropertyChangeListener,
addPropertyChangeListener,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
deliverEvent,
disable,
disableEvents,
dispatchEvent,
doLayout,
enable,
enable,
enableEvents,
enableInputMethods,
firePropertyChange,
getAlignmentX,
getAlignmentY,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentAt,
getComponentAt,
getComponentOrientation,
getCursor,
getDropTarget,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputContext,
getInputMethodRequests,
getLocale,
getLocation,
getLocation,
getLocationOnScreen,
getMaximumSize,
getName,
getParent,
getPeer,
getSize,
getSize,
getToolkit,
getTreeLock,
getWidth,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
hide,
imageUpdate,
inside,
invalidate,
isDisplayable,
isDoubleBuffered,
isEnabled,
isFocusTraversable,
isLightweight,
isOpaque,
isShowing,
isValid,
isVisible,
keyDown,
keyUp,
layout,
list,
list,
list,
list,
list,
locate,
location,
lostFocus,
minimumSize,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
paramString,
postEvent,
preferredSize,
prepareImage,
prepareImage,
print,
printAll,
processComponentEvent,
processEvent,
processFocusEvent,
processInputMethodEvent,
processKeyEvent,
processMouseEvent,
processMouseMotionEvent,
remove,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removeNotify,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
resize,
resize,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setCursor,
setDropTarget,
setEnabled,
setFont,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
show,
size,
toString,
transferFocus,
update,
validate |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
protected java.lang.String command
protected java.awt.Color color
protected java.awt.event.ActionListener actionListener
protected boolean isPressed
protected boolean isInside
protected boolean isHighlighted
| Constructor Detail |
public ColorButton()
ColorButtonpublic ColorButton(java.awt.Color color)
ColorButton initialized with the given color.color - the color to be used.public ColorButton(java.lang.String command)
ColorButton initialized with the given command.command - the command that will be passed in action events.
public ColorButton(java.lang.String command,
java.awt.Color color)
ColorButton initialized with the given command and color.command - the command that will be passed in action events.color - the color to be used.| Method Detail |
public void addActionListener(java.awt.event.ActionListener listener)
ActionListener to my set of listeners.listener - the ActionListener to add.public java.awt.Color getColor()
Color this button represents and displays.public java.lang.String getCommand()
protected java.awt.Color getDefaultColor()
protected java.lang.String getDefaultCommand()
public java.awt.Dimension getMinimumSize()
public java.awt.Dimension getPreferredSize()
public boolean isHighlighted()
true if the receiver is to be drawn highlighted;
or false otherwise.public void mouseClicked(java.awt.event.MouseEvent e)
MousePressed and MouseReleased.e - the event.public void mouseEntered(java.awt.event.MouseEvent e)
isInside flag.e - the event.public void mouseExited(java.awt.event.MouseEvent e)
isInside flag.e - the event.public void mousePressed(java.awt.event.MouseEvent e)
isPressed flag.e - the event.public void mouseReleased(java.awt.event.MouseEvent e)
processActionEvent(). Then reset the isPressed flag.e - the event.public void paint(java.awt.Graphics g)
g - the graphics object to use in painting.
public void paintHighlight(java.awt.Graphics g,
java.awt.Color firstColor,
java.awt.Color secondColor)
g - the graphics object to use in painting.firstColor - the Color to paint the top and left-hand sides.secondColor - the Color to paint the bottom and right-hand sides.public void paintHighlighted(java.awt.Graphics g)
g - the graphics object to use in painting.
public void paintLabel(java.awt.Graphics g,
int moveBy)
g - the graphics object to use in painting.moveBy - an integer representing the amount to offset the label by.public void paintUnhighlighted(java.awt.Graphics g)
g - the graphics object to use in painting.public void processActionEvent()
ActionEvent and pass it to everyone listening for it.public void removeActionListener(java.awt.event.ActionListener listener)
ActionListener from my set of listeners.listener - the ActionListener to remove.public void setColor(java.awt.Color color)
Color this button is associated with.color - the color this button should use.public void setCommand(java.lang.String command)
command - the command to be passed in action events generated.
by this button.public void setHighlighted(boolean highlighted)
highlighted - true if the button should be drawn highlighted;
false otherwise.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||