public final class SpinnerToValueModelConnector
extends java.lang.Object
SpinnerModel
,
ValueModel
Constructor and Description |
---|
SpinnerToValueModelConnector(javax.swing.SpinnerModel spinnerModel,
ValueModel valueModel,
java.lang.Object defaultValue)
Constructs a SpinnerToValueModelConnector that establishes a
Synchronization between the SpinnerModel and ValueModel.
|
Modifier and Type | Method and Description |
---|---|
static void |
connect(javax.swing.SpinnerModel spinnerModel,
ValueModel valueModel,
java.lang.Object defaultValue)
Establishes a synchronization between the SpinnerModel and ValueModel.
|
void |
release()
Removes the internal listener from the SpinnerModel and ValueModel.
|
void |
updateSpinnerModel()
Sets the subject value as spinner value.
|
void |
updateValueModel()
Sets the spinner value as value model's value.
|
public SpinnerToValueModelConnector(javax.swing.SpinnerModel spinnerModel, ValueModel valueModel, java.lang.Object defaultValue)
#updateSpinnerModel
or #updateValueModel
.
In case you don't need the connector instance, you better use
the static method connect(SpinnerModel, ValueModel, Object)
.
This constructor may confuse developers if you just use
the side effects performed in the constructor; this is because it is
quite unconventional to instantiate an object that you never use.
spinnerModel
- the SpinnerModel to be synchronizedvalueModel
- the ValueModel to be synchronizeddefaultValue
- the value that will be used to update
the spinnerModel, if the valueModel's value is null
java.lang.NullPointerException
- if the spinnerModel, valueModel or defaultValue is null
public static void connect(javax.swing.SpinnerModel spinnerModel, ValueModel valueModel, java.lang.Object defaultValue)
#updateSpinnerModel
or #updateValueModel
.spinnerModel
- the SpinnerModel to be synchronizedvalueModel
- the ValueModel to be synchronizeddefaultValue
- the value used if the valueModel's value is null
java.lang.NullPointerException
- if the spinnerModel or valueModel is null
public void updateSpinnerModel()
public void updateValueModel()
public void release()
#release
.To avoid memory leaks it is recommended to invoke this method, if the ValueModel lives much longer than the text component. Instead of releasing this connector, you typically make the ValueModel obsolete by releasing the PresentationModel or BeanAdapter that has created the ValueModel.
As an alternative you may use ValueModels that in turn use
event listener lists implemented using WeakReference
.
PresentationModel.release()
,
BeanAdapter.release()
,
WeakReference
Copyright © 2002-2010 JGoodies Karsten Lentzsch. All Rights Reserved.