|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
com.ccg.awt.TallButton
public class TallButton
A lightweight three state button that can be set quite tall. This is a lightweight component which implements a three state button. The three visual states include:
You use this object in a fashion similar to a Button (in the future it may be more similar to a JButton object). You can register yourself to listen
for events as you normally would. To customize this object, use the
following methods:
setForegroundButton).
setBackgroundButton).
setButtonPressedColor(java.awt.Color)setTextPressedColor(java.awt.Color)setTextEchoOn(boolean)setTextEchoColor(java.awt.Color)setButtonHeight(int)setMargin(int)setSemiPush(int)This class should be updated to allow button pressing via the
keyboard (not sure at the moment if this is done by looking for
ActionEvent or direct KeyEvent events.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static int |
AROUND_TEXT
Constant defining one of the focus modes supported. |
static int |
INSIDE
Constant defining one of the focus modes supported. |
static int |
NONE
Constant defining one of the focus modes supported. |
static int |
OUTSIDE
Constant defining one of the focus modes supported. |
static int |
UNDERLINE_TEXT
Constant defining one of the focus modes supported. |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
TallButton()
Initializes object to a default state. |
|
TallButton(String text,
int height,
int SemiPush,
int margin,
Color echoColor)
Construct and initialize the object. |
|
| Method Summary | |
|---|---|
void |
addActionListener(ActionListener l)
Register to receive button press notification. |
Align |
getAlign()
Get the Align object used to align the bounding box of the text |
int |
getButtonHeight()
Get the height of the button. |
Color |
getButtonPressedColor()
Get button color when the button is pressed |
Color |
getDisabledButtonColor()
Get the color to use for buttons when the button is disabled. |
Color |
getDisabledTextColor()
Get the color to use for text labels when the button is disabled. |
Color |
getFocusColor()
Get the color to use to show button has focus. |
int |
getFocusMode()
Get how the button should be "emphasized" when it has focus. |
static String[] |
getFocusModeChoices()
Get the default list of Strings used to specify focus modes. |
Insets |
getInsets()
Get how much the component should be inset from edges. |
int |
getMargin()
Get the amount of desired margin space around the text the button. |
Color |
getMouseOverColor()
Get the color of the button when the mouse pointer is over it |
MultiLineText |
getMultiLineText()
Get the MultiLineText object which has the text |
Dimension |
getPreferredSize()
Computes the preferred size of the button. |
int |
getSemiPush()
Get the semi depress value of the button. |
String |
getText()
Get the text label which appears on the button. |
Color |
getTextEchoColor()
Get the color used when echoing text to show user what button they are on. |
Color |
getTextEchoReleasedColor()
Get the color used when echoing text on a button in a released state. |
Color |
getTextPressedColor()
Get the color of the text when the button is pressed. |
boolean |
isEmphasized()
Should the button be emphasized (is the mouse over it)? |
boolean |
isFocusTraversable()
Indicate that component can be traversed using keyboard. |
boolean |
isPressed()
Is the button currently "pressed" (being held down). |
boolean |
isTextEchoOn()
Is text echoed (hightlighted) when button has focus? |
void |
paint(Graphics g)
Paints the component on a graphics context. |
void |
paintInsets(Graphics g)
Paints the "inset" border on a graphics context. |
void |
paintText(Graphics g)
Paints the text component on a graphics context. |
void |
processEvent(AWTEvent e)
Monitor for certain MOUSE/KEYBOARD events. |
void |
removeActionListener(ActionListener l)
Deregister to receive button press notification. |
void |
set(TagLookup info)
Set properties for button based on values in TagLookup table. |
void |
setAlign(Align val)
Set the Align object used to align the bounding box of the text |
void |
setButtonHeight(int h)
Set the height of the button. |
void |
setButtonPressedColor(Color val)
Set button color when the button is pressed |
void |
setEnabled(boolean state)
Set whether the button should be enabled or disabled. |
void |
setFocusColor(Color val)
Set the color to use to show button has focus. |
void |
setFocusMode(int val)
Set how the button should be "emphasized" when it has focus. |
void |
setInsets(Insets val)
Set how much the component should be inset from edges This property controls how much clear area should exist at the edges of the component. |
void |
setMargin(int margin)
Set the amount of margin space around text on top of the button. |
void |
setMouseOverColor(Color val)
Set the color of the button when the mouse pointer is over it
You can set this value to 'null' to force the mouse over color to
match the "released" state of the button. |
void |
setMultiLineText(MultiLineText val)
Set the MultiLineText object which has the text |
void |
setSemiPush(int v)
Set the semi depressed value of the button. |
void |
setText(String text)
Set the text label which appears on the button. |
void |
setTextEchoColor(Color c)
Set the "echo" color when button has the focus. |
void |
setTextEchoOn(boolean val)
Set text echoed (hightlighted) when button has focus. |
void |
setTextEchoReleasedColor(Color c)
Set the "echo" color when button is released. |
void |
setTextPressedColor(Color c)
Set the color of the text when the button is pressed. |
void |
update(Graphics g)
Disable clearing of component area. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int NONE
focus modes supported.
setFocusMode(int),
Constant Field Valuespublic static final int OUTSIDE
focus modes supported.
setFocusMode(int),
Constant Field Valuespublic static final int INSIDE
focus modes supported.
setFocusMode(int),
Constant Field Valuespublic static final int AROUND_TEXT
focus modes supported.
setFocusMode(int),
Constant Field Valuespublic static final int UNDERLINE_TEXT
focus modes supported.
setFocusMode(int),
Constant Field Values| Constructor Detail |
|---|
public TallButton()
text which appears on the button if you initialize it
in this fashion.
TallButton(String,int,int,int,Color)
public TallButton(String text,
int height,
int SemiPush,
int margin,
Color echoColor)
text - The text label which will appear on the button.height - The desired height of the button (set to -1 to leave it at the
default setting).semiDepress - How many pixel lines the button should appear to press down on
focus (see setSemiPush(int) for details. Set to -1 to
leave in its default state (must be less than height).margin - How many pixels of space you would like as a minimum around
the text which appears on the top of the button. Set to -1 to
leave it at the default value.echoColor - Pass a non-null color (like Color.white)
if you want to enable text echoing when the cursor enters the
component space. Pass null if you want to disable text
echoing.TallButton()| Method Detail |
|---|
public void set(TagLookup info)
throws ParseException
TagLookup table.
This method will set all of the properties it can find from the
specified TagLookup table. The "keys" which we
recognize are as follows:
setText(java.lang.String)Component.setFont(java.awt.Font)TagLookup.getFont(java.lang.String, java.awt.Font) for details on
specifying font strings.
setButtonHeight(int)setMargin(int)setSemiPush(int)Component.setForeground(java.awt.Color)TagLookup.getColor(java.lang.String, java.awt.Color) for details on specifying colors.
Component.setBackground(java.awt.Color)TagLookup.getColor(java.lang.String, java.awt.Color) for details on specifying colors.
setTextPressedColor(java.awt.Color)TagLookup.getColor(java.lang.String, java.awt.Color) for details on specifying colors.
setTextEchoOn(boolean)TagLookup.getBoolean(java.lang.String, java.lang.Boolean) for details on
specifying colors (or use "true"/"false").
setTextEchoColor(java.awt.Color)TagLookup.getColor(java.lang.String, java.awt.Color) for details on specifying colors.
setTextEchoReleasedColor(java.awt.Color)TagLookup.getColor(java.lang.String, java.awt.Color) for details on specifying
colors.
setButtonPressedColor(java.awt.Color)TagLookup.getColor(java.lang.String, java.awt.Color) for details on specifying
colors.
setMouseOverColor(java.awt.Color)TagLookup.getColor(java.lang.String, java.awt.Color) for details on specifying colors.
setFocusMode(int)getFocusModeChoices() and is used to set the focus mode.
setFocusColor(java.awt.Color)TagLookup.getColor(java.lang.String, java.awt.Color) for details on specifying colors.
setInsets(java.awt.Insets)).
aligned. Valid values: "c"
- centered, "l" - left, "r" - right. This parameter has no affect if you have a single line of
text.
aligned. By default, this will be
"cp.5,cp.5" which results in text centered on the button. Refer
to Align.parse(java.lang.String) for details on the numerous ways to adjust
the alignment.
tl - A TagLookup to fetch values from.
ParseExceptionpublic void setFocusMode(int val)
Use one of the following constants to define how the button should appear when it has the focus:
NONEOUTSIDEfocus color around the outside of the button.
INSIDEfocus color around the flat top of the button.
AROUND_TEXTUNDERLINE_TEXT
val - New int value to assign (if you specify a unrecognized value -
it will be ignored).getFocusMode()public int getFocusMode()
setFocusMode(int)public static String[] getFocusModeChoices()
set(com.ccg.util.TagLookup) method, but could be
used by others as well. The string names and their corresponding
focus modes are:
"None" -NONE"Outside" -OUTSIDE"Inside" -INSIDE"TextBox" -AROUND_TEXT"Underline" -UNDERLINE_TEXT
Here's a quick example of how one might use this method:
public static void changeFocusMode(TallButton[] buttons, String val) {
int mode = TagLookup.choiceValue(val,TallButton.getFocusModeChoices());
// if "mode" specified, go set
if (mode >= 0) for (int i = 0; i < buttons.length; i++) {
buttons[i].setFocusMode(mode);
}
}
Convert.choiceValue(java.lang.String, java.lang.String[]),
TagLookup.getChoice(java.lang.String, java.lang.String[])public void setFocusColor(Color val)
val - New Color value to assign (if you pass null - it will be
ignored).getFocusColor()public Color getFocusColor()
setFocusColor(java.awt.Color)public void setText(String text)
margin
border specified.
text - Sets the text label which appears on the button (you may pass
null or a zero length string to disable the display of text).getText()public String getText()
setText(java.lang.String)public void setButtonHeight(int h)
setSemiPush(int) value as well (since its maximum value is
limited to the height of the button).
h - Sets the height of the button (if the value is less than 0, it
is ignored).getButtonHeight()public int getButtonHeight()
setButtonHeight(int)public void setSemiPush(int v)
h - Sets the semi of the button (if the value is less than 0, or
greater than the height it is ignored.getSemiPush()public int getSemiPush()
setSemiPush(int)public void setMargin(int margin)
margin - Sets the amount of space desired around the text (values less
than zero are ignored).getMargin()public int getMargin()
setMargin(int)public void setTextPressedColor(Color c)
color - New color to set (if you pass null it will be ignored).getTextPressedColor()public Color getTextPressedColor()
setTextPressedColor(java.awt.Color)public void setTextEchoColor(Color c)
color when button has the focus.
c - The Color to use for emphasizing the text of
the button which has the focus. Pass null if you want to
disable this feature.getTextEchoColor(),
setTextEchoOn(boolean)public Color getTextEchoColor()
echoing is enabled to
highlight the text on the button with the current focus.setTextEchoColor(java.awt.Color)public void setTextEchoReleasedColor(Color c)
color when button is released.
c - The Color to use for emphasizing the text of
the button which is released (in a up state), but which
doesn't have the mouse over it. Pass null if you want to
disable this feature.getTextEchoReleasedColor(),
setTextEchoOn(boolean)public Color getTextEchoReleasedColor()
echoing is enabled to
highlight the text on the button which is released (up), but
doesn't have the mouse pointer floating on top.setTextEchoReleasedColor(java.awt.Color)public void setTextEchoOn(boolean val)
val - New boolean value to assign - set to true to enable echoing
feature, false to disable.
see #getTextEchoOnpublic boolean isTextEchoOn()
public void setButtonPressedColor(Color val)
val - New Color value to assign (if you pass null your value will be
ignored).getButtonPressedColor()public Color getButtonPressedColor()
setButtonPressedColor(java.awt.Color)public void setInsets(Insets val)
val - New Insets value to assign.getInsets()public Insets getInsets()
setInsets(java.awt.Insets)public void update(Graphics g)
paint(java.awt.Graphics) method completely draws the component,
we can override the default implementation of the update method
so that it won't blank our components area (since we will fill it
anyway).
update in class Componentg - Graphics context to draw button image onto.paint(java.awt.Graphics)public void paint(Graphics g)
graphics context.
This method takes care of drawing the button in its proper
state. The following items are taken into consideration (the
settings of the object determine color and whether or not they
are done):
paint in class Componentg - Graphics context to draw button image onto.paintText(java.awt.Graphics)public void paintText(Graphics g)
graphics context.
This method takes care of drawing the text in it's proper state.
The following items are taken into consideration (the settings of
the object determine color and whether or not they are done):
g - Graphics context to draw button text onto.paint(java.awt.Graphics)public void paintInsets(Graphics g)
graphics context.
This method takes care of drawing the flat border around the
edges of the component (if the insets is not set to a zero size).
g - Graphics context to insets onto.paint(java.awt.Graphics)public Dimension getPreferredSize()
height, margin,
and text requirements will be fullfilled to
properly draw the button.
getPreferredSize in class Componentpublic void processEvent(AWTEvent e)
processEvent in class Componente - The event which is occurring.public boolean isFocusTraversable()
isFocusTraversable in class Componentpublic void addActionListener(ActionListener l)
l - A ActionListener who wants to be
notified when the user presses the button (notification is
actually during the release).removeActionListener(java.awt.event.ActionListener)public void removeActionListener(ActionListener l)
l - A ActionListener who no longer wants to
be notified when the user presses the button (notification is
actually during the release).addActionListener(java.awt.event.ActionListener)public boolean isPressed()
isEmphasized()public boolean isEmphasized()
isPressed()public void setAlign(Align val)
Align object used to align the bounding box of the text
val - New Align value to assign.getAlign()public Align getAlign()
Align object used to align the bounding box of the text
setAlign(com.ccg.awt.Align)public void setMultiLineText(MultiLineText val)
MultiLineText object which has the text
val - New MultiLineText value to assign.getMultiLineText()public MultiLineText getMultiLineText()
MultiLineText object which has the text
setMultiLineText(com.ccg.awt.MultiLineText)public void setMouseOverColor(Color val)
color of the button when the mouse pointer is over it
You can set this value to 'null' to force the mouse over color to
match the "released" state of the button.
val - New Color value to assign.getMouseOverColor()public Color getMouseOverColor()
color of the button when the mouse pointer is over it
setMouseOverColor(java.awt.Color)public Color getDisabledButtonColor()
color to use for buttons in a disabled state.getDisabledTextColor()public Color getDisabledTextColor()
color to use for disabled text labels.getDisabledButtonColor()public void setEnabled(boolean state)
This method is used to enable/disable the button. A disabled button will be drawn differently and will not work (won't do anything) when the user presses it.
setEnabled in class Componentenable - Pass true to enable the button to function, pass false to put
the button in its "disabled" state.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||