Package groovy.swing.model
Class ValueHolder
java.lang.Object
groovy.swing.model.ValueHolder
- All Implemented Interfaces:
ValueModel
A mutable
ValueModel implementation that stores a local value and optionally emits change events.-
Constructor Summary
ConstructorsConstructorDescriptionCreates a holder withObjectas its declared type.ValueHolder(Class type) Creates a holder with the supplied declared type.ValueHolder(Object value) Creates a holder initialized with the supplied value. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a PropertyChangeListener to the listener list.getType()Returns the declared value type for this holder.getValue()Returns the current stored value.booleanIndicates whether callers should treat this holder as writable.voidRemoves a PropertyChangeListener from the listener list.voidsetEditable(boolean editable) Controls whether callers should treat this holder as writable.voidUpdates the current value and notifies registered listeners of the change.
-
Constructor Details
-
ValueHolder
public ValueHolder()Creates a holder withObjectas its declared type. -
ValueHolder
Creates a holder with the supplied declared type.- Parameters:
type- the declared value type
-
ValueHolder
Creates a holder initialized with the supplied value.- Parameters:
value- the initial value
-
-
Method Details
-
addPropertyChangeListener
Add a PropertyChangeListener to the listener list.- Parameters:
listener- The listener to add.
-
removePropertyChangeListener
Removes a PropertyChangeListener from the listener list.- Parameters:
listener- The listener to remove.
-
getValue
Returns the current stored value.- Specified by:
getValuein interfaceValueModel- Returns:
- the current value
-
setValue
Updates the current value and notifies registered listeners of the change.- Specified by:
setValuein interfaceValueModel- Parameters:
value- the new value
-
getType
Returns the declared value type for this holder.- Specified by:
getTypein interfaceValueModel- Returns:
- the holder type
-
isEditable
public boolean isEditable()Indicates whether callers should treat this holder as writable.- Specified by:
isEditablein interfaceValueModel- Returns:
truewhen the holder is editable
-
setEditable
public void setEditable(boolean editable) Controls whether callers should treat this holder as writable.- Parameters:
editable-trueto mark the holder as editable
-