com.jgoodies.binding.adapter
Class PreferencesAdapter
- Observable, Serializable, ValueModel
public final class PreferencesAdapter
A ValueModel implementation that reads and writes values from/to a key
of a given
Preferences
node under a specified key.
Write changes fire value changes.
Example:
String prefsKey = "isShowing";
Boolean defaultValue = Boolean.TRUE;
Preferences prefs = Workbench.userPreferences();
ValueModel model = new PreferencesAdapter(prefs, prefsKey, defaultValue);
JCheckBox showingBox = new JCheckBox("Show tips");
showingBox.setModel(new ToggleButtonAdapter(model));
java.util.prefs.Preferences
PreferencesAdapter(Preferences prefs, String key, Object defaultValue) - Constructs a PreferencesAdapter on the given
Preferences
using the specified key and default value, all which must be
non-null .
|
@Override | String getString() - Looks up, converts and returns the stored value from the preferences.
|
boolean | getBoolean() - Looks up, converts and returns the stored value from the preferences.
|
double | getDouble() - Looks up, converts and returns the stored value from the preferences.
|
float | getFloat() - Looks up, converts and returns the stored value from the preferences.
|
int | getInt() - Looks up, converts and returns the stored value from the preferences.
|
long | getLong() - Looks up, converts and returns the stored value from the preferences.
|
Object | getValue() - Looks up and returns the value from the preferences.
|
void | setBoolean(boolean newValue) - Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
|
void | setDouble(double newValue) - Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
|
void | setFloat(float newValue) - Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
|
void | setInt(int newValue) - Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
|
void | setLong(long newValue) - Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
|
void | setString(String newValue) - Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
|
void | setValue(Object newValue) - Converts the given value to a string and puts it into the preferences.
|
String toString , addValueChangeListener , booleanValue , doubleValue , fireValueChange , fireValueChange , fireValueChange , fireValueChange , fireValueChange , fireValueChange , fireValueChange , floatValue , getString , intValue , longValue , removeValueChangeListener , setValue , setValue , setValue , setValue , setValue |
addPropertyChangeListener , addPropertyChangeListener , addVetoableChangeListener , addVetoableChangeListener , equals , fireIndexedPropertyChange , fireIndexedPropertyChange , fireIndexedPropertyChange , fireMultiplePropertiesChanged , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , fireVetoableChange , fireVetoableChange , fireVetoableChange , fireVetoableChange , fireVetoableChange , fireVetoableChange , fireVetoableChange , getPropertyChangeListeners , getPropertyChangeListeners , getVetoableChangeListeners , getVetoableChangeListeners , removePropertyChangeListener , removePropertyChangeListener , removeVetoableChangeListener , removeVetoableChangeListener |
PreferencesAdapter
public PreferencesAdapter(Preferences prefs,
String key,
Object defaultValue)
Constructs a PreferencesAdapter on the given Preferences
using the specified key and default value, all which must be
non-null
.
prefs
- the Preferences
used to store and retrievekey
- the key used to get and set values in the PreferencesdefaultValue
- the default value
String getString
public @Override String getString()
Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
- the stored value or the default
getBoolean
public boolean getBoolean()
Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
- the stored value or the default
getDouble
public double getDouble()
Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
- the stored value or the default
getFloat
public float getFloat()
Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
- the stored value or the default
getInt
public int getInt()
Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
- the stored value or the default
getLong
public long getLong()
Looks up, converts and returns the stored value from the preferences.
Returns the default value if no value has been stored before.
- the stored value or the default
getValue
public Object getValue()
Looks up and returns the value from the preferences. The value is
look up under this adapter's key. It will be converted before it is
returned.
- getValue in interface ValueModel
- the retrieved and converted value
setBoolean
public void setBoolean(boolean newValue)
Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
newValue
- the value to put into the Preferences
setDouble
public void setDouble(double newValue)
Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
newValue
- the value to put into the Preferences
setFloat
public void setFloat(float newValue)
Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
newValue
- the value to put into the Preferences
setInt
public void setInt(int newValue)
Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
newValue
- the value to put into the Preferences
setLong
public void setLong(long newValue)
Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
newValue
- the value to put into the Preferences
setString
public void setString(String newValue)
Converts the given value to an Object and stores it in this
adapter's Preferences under this adapter's preferences key.
newValue
- the value to put into the Preferences
setValue
public void setValue(Object newValue)
Converts the given value to a string and puts it into the preferences.
- setValue in interface ValueModel
newValue
- the object to be stored
Copyright © 2002-2007 JGoodies Karsten Lentzsch. All Rights Reserved.