public final class ColorSelectionAdapter extends DefaultColorSelectionModel
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.PROPERTY_COLOR); JColorChooser colorChooser = BasicComponentFactory.createColorChooser(model); // Binding using the Bindings class ValueModel model = presentationModel.getModel(MyBean.PROPERTY_COLOR); JColorChooser colorChooser = new JColorChooser(); Bindings.bind(colorChooser, model); // Hand-made binding ValueModel model = presentationModel.getModel(MyBean.PROPERTY_COLOR); JColorChooser colorChooser = new JColorChooser(new ColorSelectionAdapter(model));
ColorSelectionModel,
JColorChooser,
Serialized FormchangeEvent, listenerList| Constructor and Description |
|---|
ColorSelectionAdapter(ValueModel subject)
Constructs a ColorSelectionAdapter on the given subject ValueModel.
|
ColorSelectionAdapter(ValueModel subject,
Color defaultColor)
Constructs a ColorSelectionAdapter on the given subject ValueModel.
|
| Modifier and Type | Method and Description |
|---|---|
Color |
getSelectedColor()
Returns the selected Color which should be non-
null. |
void |
setSelectedColor(Color color)
Sets the selected color to
color. |
addChangeListener, fireStateChanged, getChangeListeners, removeChangeListenerpublic ColorSelectionAdapter(ValueModel subject)
subject - the subject that holds the valueNullPointerException - if the subject is null.public ColorSelectionAdapter(ValueModel subject, Color defaultColor)
subject - the subject that holds the valuedefaultColor - an optional default color that is used as
selected color if the subject returns nullNullPointerException - if subject is nullpublic 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 ColorSelectionModelgetSelectedColor in class DefaultColorSelectionModelClassCastException - if the subject value is not a ColorsetSelectedColor(Color)public void setSelectedColor(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 ColorSelectionModelsetSelectedColor in class DefaultColorSelectionModelcolor - the new ColorgetSelectedColor()Copyright © 2002-2015 JGoodies Software GmbH. All Rights Reserved.