|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.colorchooser.DefaultColorSelectionModel
com.jgoodies.binding.adapter.ColorSelectionAdapter
public final class ColorSelectionAdapter
Converts ValueModels to the ColorSelectionModel interface. Useful to bind JColorChooser and similar classes to a ValueModel.
Constraints: The subject ValueModel must be of type Color
and must allow read-access to its value. Also, it is strongly recommended
(though not required) that the underlying ValueModel provides only non-null
values. This is so because the ColorSelectionModel behavior is undefined
for null values and it may have unpredictable results.
Examples:
// Recommended binding style using a factory ValueModel model = presentationModel.getModel(MyBean.PROPERTYNAME_COLOR); JColorChooser colorChooser = BasicComponentFactory.createColorChooser(model); // Binding using the Bindings class ValueModel model = presentationModel.getModel(MyBean.PROPERTYNAME_COLOR); JColorChooser colorChooser = new JColorChooser(); Bindings.bind(colorChooser, model); // Hand-made binding ValueModel model = presentationModel.getModel(MyBean.PROPERTYNAME_COLOR); JColorChooser colorChooser = new JColorChooser(new ColorSelectionAdapter(model));
ColorSelectionModel,
JColorChooser,
Serialized Form| Field Summary |
|---|
| Fields inherited from class javax.swing.colorchooser.DefaultColorSelectionModel |
|---|
changeEvent, listenerList |
| Constructor Summary | |
|---|---|
ColorSelectionAdapter(ValueModel subject)
Constructs a ColorSelectionAdapter on the given subject ValueModel. |
|
ColorSelectionAdapter(ValueModel subject,
java.awt.Color defaultColor)
Constructs a ColorSelectionAdapter on the given subject ValueModel. |
|
| Method Summary | |
|---|---|
java.awt.Color |
getSelectedColor()
Returns the selected Color which should be non- null. |
void |
setSelectedColor(java.awt.Color color)
Sets the selected color to color. |
| Methods inherited from class javax.swing.colorchooser.DefaultColorSelectionModel |
|---|
addChangeListener, fireStateChanged, getChangeListeners, removeChangeListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ColorSelectionAdapter(ValueModel subject)
subject - the subject that holds the value
java.lang.NullPointerException - if the subject is null.
public ColorSelectionAdapter(ValueModel subject,
java.awt.Color defaultColor)
subject - the subject that holds the valuedefaultColor - an optional default color that is used as
selected color if the subject returns null
java.lang.NullPointerException - if the subject is null.| Method Detail |
|---|
public java.awt.Color getSelectedColor()
null.
The return value is the subject value model's value, if non-null,
otherwise the default color. Note that the latter may be null too.
getSelectedColor in interface javax.swing.colorchooser.ColorSelectionModelgetSelectedColor in class javax.swing.colorchooser.DefaultColorSelectionModeljava.lang.ClassCastException - if the subject value is not a ColorsetSelectedColor(Color)public void setSelectedColor(java.awt.Color color)
color.
Note that setting the color to null
is undefined and may have unpredictable results.
This method fires a state changed event if it sets the
current color to a new non-null color.
setSelectedColor in interface javax.swing.colorchooser.ColorSelectionModelsetSelectedColor in class javax.swing.colorchooser.DefaultColorSelectionModelcolor - the new ColorgetSelectedColor()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||