public class PreferencesUtil
extends java.util.prefs.Preferences
PreferencesUtil
provides utility methods for java.util.prefs.Preferences
, and can be used as a proxy when the system
preferences are not available due to security restrictions.Constructor and Description |
---|
PreferencesUtil(boolean isUserNode) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
absolutePath() |
void |
addNodeChangeListener(java.util.prefs.NodeChangeListener ncl) |
void |
addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener pcl) |
java.lang.String[] |
childrenNames() |
void |
clear() |
void |
exportNode(java.io.OutputStream os) |
void |
exportSubtree(java.io.OutputStream os) |
void |
flush() |
java.lang.String |
get(java.lang.String key,
java.lang.String def) |
boolean |
getBoolean(java.lang.String key,
boolean def) |
byte[] |
getByteArray(java.lang.String key,
byte[] def) |
double |
getDouble(java.lang.String key,
double def) |
float |
getFloat(java.lang.String key,
float def) |
int |
getInt(java.lang.String key,
int def) |
long |
getLong(java.lang.String key,
long def) |
static void |
installFramePrefsHandler(java.util.prefs.Preferences prefs,
java.lang.String name,
java.awt.Window window)
Installs a frame preferences handler.
|
static void |
installFramePrefsHandler(java.util.prefs.Preferences prefs,
java.lang.String name,
java.awt.Window window,
java.awt.Dimension defaultSize)
Installs a frame preferences handler.
|
static void |
installInternalFramePrefsHandler(java.util.prefs.Preferences prefs,
java.lang.String name,
javax.swing.JInternalFrame window,
javax.swing.JDesktopPane desktop)
Installs an intenal frame preferences handler.
|
static void |
installPalettePrefsHandler(java.util.prefs.Preferences prefs,
java.lang.String name,
java.awt.Window window)
Installs a palette preferences handler.
|
static void |
installPalettePrefsHandler(java.util.prefs.Preferences prefs,
java.lang.String name,
java.awt.Window window,
int x) |
static void |
installPrefsHandler(java.util.prefs.Preferences prefs,
java.lang.String string,
javax.swing.JTabbedPane tabbedPane) |
static void |
installTabbedPanePrefsHandler(java.util.prefs.Preferences prefs,
java.lang.String name,
javax.swing.JTabbedPane tabbedPane)
Installs a JTabbedPane preferences handler.
|
static void |
installToolBarPrefsHandler(java.util.prefs.Preferences prefs,
java.lang.String name,
javax.swing.JToolBar toolbar)
Installs a toolbar preferences handler.
|
boolean |
isUserNode() |
java.lang.String[] |
keys() |
java.lang.String |
name() |
java.util.prefs.Preferences |
node(java.lang.String pathName) |
boolean |
nodeExists(java.lang.String pathName) |
java.util.prefs.Preferences |
parent() |
void |
put(java.lang.String key,
java.lang.String value) |
void |
putBoolean(java.lang.String key,
boolean value) |
void |
putByteArray(java.lang.String key,
byte[] value) |
void |
putDouble(java.lang.String key,
double value) |
void |
putFloat(java.lang.String key,
float value) |
void |
putInt(java.lang.String key,
int value) |
void |
putLong(java.lang.String key,
long value) |
void |
remove(java.lang.String key) |
void |
removeNode() |
void |
removeNodeChangeListener(java.util.prefs.NodeChangeListener ncl) |
void |
removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener pcl) |
void |
sync() |
static java.util.prefs.Preferences |
systemNodeForPackage(java.lang.Class<?> c)
Gets the system node for the package of the class if
permitted, gets a proxy otherwise.
|
java.lang.String |
toString() |
static java.util.prefs.Preferences |
userNodeForPackage(java.lang.Class<?> c)
Gets the user node for the package of the class if
permitted, gets a proxy otherwise.
|
public void put(java.lang.String key, java.lang.String value)
put
in class java.util.prefs.Preferences
public java.lang.String get(java.lang.String key, java.lang.String def)
get
in class java.util.prefs.Preferences
public void remove(java.lang.String key)
remove
in class java.util.prefs.Preferences
public void clear() throws java.util.prefs.BackingStoreException
clear
in class java.util.prefs.Preferences
java.util.prefs.BackingStoreException
public void putInt(java.lang.String key, int value)
putInt
in class java.util.prefs.Preferences
public int getInt(java.lang.String key, int def)
getInt
in class java.util.prefs.Preferences
public void putLong(java.lang.String key, long value)
putLong
in class java.util.prefs.Preferences
public long getLong(java.lang.String key, long def)
getLong
in class java.util.prefs.Preferences
public void putBoolean(java.lang.String key, boolean value)
putBoolean
in class java.util.prefs.Preferences
public boolean getBoolean(java.lang.String key, boolean def)
getBoolean
in class java.util.prefs.Preferences
public void putFloat(java.lang.String key, float value)
putFloat
in class java.util.prefs.Preferences
public float getFloat(java.lang.String key, float def)
getFloat
in class java.util.prefs.Preferences
public void putDouble(java.lang.String key, double value)
putDouble
in class java.util.prefs.Preferences
public double getDouble(java.lang.String key, double def)
getDouble
in class java.util.prefs.Preferences
public void putByteArray(java.lang.String key, byte[] value)
putByteArray
in class java.util.prefs.Preferences
public byte[] getByteArray(java.lang.String key, byte[] def)
getByteArray
in class java.util.prefs.Preferences
public java.lang.String[] keys() throws java.util.prefs.BackingStoreException
keys
in class java.util.prefs.Preferences
java.util.prefs.BackingStoreException
public java.lang.String[] childrenNames() throws java.util.prefs.BackingStoreException
childrenNames
in class java.util.prefs.Preferences
java.util.prefs.BackingStoreException
public java.util.prefs.Preferences parent()
parent
in class java.util.prefs.Preferences
public java.util.prefs.Preferences node(java.lang.String pathName)
node
in class java.util.prefs.Preferences
public boolean nodeExists(java.lang.String pathName) throws java.util.prefs.BackingStoreException
nodeExists
in class java.util.prefs.Preferences
java.util.prefs.BackingStoreException
public void removeNode() throws java.util.prefs.BackingStoreException
removeNode
in class java.util.prefs.Preferences
java.util.prefs.BackingStoreException
public java.lang.String name()
name
in class java.util.prefs.Preferences
public java.lang.String absolutePath()
absolutePath
in class java.util.prefs.Preferences
public boolean isUserNode()
isUserNode
in class java.util.prefs.Preferences
public java.lang.String toString()
toString
in class java.util.prefs.Preferences
public void flush() throws java.util.prefs.BackingStoreException
flush
in class java.util.prefs.Preferences
java.util.prefs.BackingStoreException
public void sync() throws java.util.prefs.BackingStoreException
sync
in class java.util.prefs.Preferences
java.util.prefs.BackingStoreException
public void addPreferenceChangeListener(java.util.prefs.PreferenceChangeListener pcl)
addPreferenceChangeListener
in class java.util.prefs.Preferences
public void removePreferenceChangeListener(java.util.prefs.PreferenceChangeListener pcl)
removePreferenceChangeListener
in class java.util.prefs.Preferences
public void addNodeChangeListener(java.util.prefs.NodeChangeListener ncl)
addNodeChangeListener
in class java.util.prefs.Preferences
public void removeNodeChangeListener(java.util.prefs.NodeChangeListener ncl)
removeNodeChangeListener
in class java.util.prefs.Preferences
public void exportNode(java.io.OutputStream os) throws java.io.IOException, java.util.prefs.BackingStoreException
exportNode
in class java.util.prefs.Preferences
java.io.IOException
java.util.prefs.BackingStoreException
public void exportSubtree(java.io.OutputStream os) throws java.io.IOException, java.util.prefs.BackingStoreException
exportSubtree
in class java.util.prefs.Preferences
java.io.IOException
java.util.prefs.BackingStoreException
public static java.util.prefs.Preferences systemNodeForPackage(java.lang.Class<?> c)
public static java.util.prefs.Preferences userNodeForPackage(java.lang.Class<?> c)
public static void installPrefsHandler(java.util.prefs.Preferences prefs, java.lang.String string, javax.swing.JTabbedPane tabbedPane)
public static void installFramePrefsHandler(java.util.prefs.Preferences prefs, java.lang.String name, java.awt.Window window)
If no preferences are stored yet for this window, a default size of 400 x 300 pixels is used.
prefs
- Preferences for storing/retrieving preferences values.name
- Base name of the preference.window
- The window for which to track preferences.public static void installFramePrefsHandler(java.util.prefs.Preferences prefs, java.lang.String name, java.awt.Window window, java.awt.Dimension defaultSize)
prefs
- Preferences for storing/retrieving preferences values.name
- Base name of the preference.window
- The window for which to track preferences.defaultSize
- This size is used when no prefences are stored yet for this window.public static void installPalettePrefsHandler(java.util.prefs.Preferences prefs, java.lang.String name, java.awt.Window window)
prefs
- Preferences for storing/retrieving preferences values.name
- Base name of the preference.window
- The window for which to track preferences.public static void installPalettePrefsHandler(java.util.prefs.Preferences prefs, java.lang.String name, java.awt.Window window, int x)
public static void installInternalFramePrefsHandler(java.util.prefs.Preferences prefs, java.lang.String name, javax.swing.JInternalFrame window, javax.swing.JDesktopPane desktop)
prefs
- Preferences for storing/retrieving preferences values.name
- Base name of the preference.window
- The window for which to track preferences.public static void installToolBarPrefsHandler(java.util.prefs.Preferences prefs, java.lang.String name, javax.swing.JToolBar toolbar)
prefs
- Preferences for storing/retrieving preferences values.name
- Base name of the preference.toolbar
- The JToolBar for which to track preferences.public static void installTabbedPanePrefsHandler(java.util.prefs.Preferences prefs, java.lang.String name, javax.swing.JTabbedPane tabbedPane)
prefs
- Preferences for storing/retrieving preferences values.name
- Base name of the preference.tabbedPane
- The JTabbedPane for which to track preferences.