|
||||||||||
| 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
com.ccg.swing.ColorButton
public class ColorButton
A swing button used to allow the user to pick a color - the button displays the color if user clicks button they can change it.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JButton |
|---|
JButton.AccessibleJButton |
| Nested classes/interfaces inherited from class javax.swing.AbstractButton |
|---|
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| 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 | |
|---|---|
ColorButton()
Construct a default "blue" button. |
|
| Method Summary | |
|---|---|
Color |
getColor()
Get the color which is currently assigned. |
static MessageFormat |
getGlobalLabelFormat()
Get the global format to use for labeling the button. |
MessageFormat |
getLabelFormat()
Get the format to use for labeling the button. |
void |
setColor(Color c)
Set the color which is currently assigned. |
void |
setColorAndNotify(Color c)
Set the color associated with the button and
notify any "item listeners" if it is a change in color. |
static void |
setGlobalLabelFormat(MessageFormat val)
Set the global format to use for labeling the button. |
void |
setLabelFormat(MessageFormat val)
Set the format to use for labeling the button. |
| 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 |
| Constructor Detail |
|---|
public ColorButton()
| Method Detail |
|---|
public void setColor(Color c)
color which is currently assigned.
val - New Color value to assign.getColor()public void setColorAndNotify(Color c)
color associated with the button and
notify any "item listeners" if it is a change in color.
This method is similar to the setColor method in that
it allows one to change the color associated with the button. However,
this method checks to see if the new color is an actual change or not
from the current color. If it is an actual change in color, then all
registered "item listeners" (via the
addItemListener method) will be notified.
val - New Color value to assign (if you pass null, we do nothing and silently
return).public Color getColor()
color which is currently assigned.
setColor(java.awt.Color)public void setLabelFormat(MessageFormat val)
This method allows one to specify a specific MessageFormat to use for creating a label for the button. If
you specify null or an invalid format, then the global label format will
be used. The default format (if you never specify one) is:
"{0}-{1}-{2}"
The "{0}", "{1}" and "{2}" values will be subsituted with the value of the red, green and blue values of the color (each which will range from 0 to 255. If you specify a invalid format, then the format specified will be ignored.
NOTE: You don't need to use the special variables "{0}", "{1}", or "{2}". You can omit all of them if you just want a simple label. Try something like "My Button" to see what happens.
val - New MessageFormat value to assign, or specify null to fall back to the
global format.getLabelFormat(),
setGlobalLabelFormat(java.text.MessageFormat)public MessageFormat getLabelFormat()
Note, if a specific label format hasn't been defined for the button, then the global format will be returned - this method will never return null.
setLabelFormat(java.text.MessageFormat)public static void setGlobalLabelFormat(MessageFormat val)
This method allows one to specify a specific MessageFormat to use for ALL ColorButton
objects which don't specify their own specific format (this is the global
default format). If you specify null, then the built-in format will be
used. If you specify a invalid format, then your format will be ignored.
The default format (if you never specify one) is:
"{0}-{1}-{2}"
The "{0}", "{1}" and "{2}" values will be subsituted with the value of the red, green and blue values of the color (each which will range from 0 to 255.
val - New MessageFormat value to assign, or specify null to fall back to the
global format.getGlobalLabelFormat(),
setLabelFormat(java.text.MessageFormat)public static MessageFormat getGlobalLabelFormat()
This is the global defualt method for labeling the buttons (if you don't specify a different format).
Note, if a global format has never been specified (or set back to null), then the built-in default format will be returned. This method never returns null.
setGlobalLabelFormat(java.text.MessageFormat)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||