Java Code Examples for java.util.prefs.Preferences#removePreferenceChangeListener()
The following examples show how to use
java.util.prefs.Preferences#removePreferenceChangeListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreferenceUtilites.java From constellation with Apache License 2.0 | 6 votes |
/** * Remove a PreferenceChangeListener from a specified preference node. * * @param preferenceNode The preference node being listened to. * @param pcl A PreferenceChangeListener * * @return True if the addPreferenceChangeListener() worked, false * otherwise. */ public static boolean removePreferenceChangeListener(final String preferenceNode, final PreferenceChangeListener pcl) { try { Preferences p = NbPreferences.root(); if (p.nodeExists(preferenceNode)) { p = p.node(preferenceNode); p.removePreferenceChangeListener(pcl); return true; } } catch (BackingStoreException ex) { Exceptions.printStackTrace(ex); } return false; }
Example 2
Source File: UnitTab.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void removeNotify () { super.removeNotify (); if (dlForSearch != null) { tfSearch.getDocument ().removeDocumentListener (getDocumentListener ()); } dlForSearch = null; if (flForSearch != null) { tfSearch.removeFocusListener(flForSearch); } flForSearch = null; Preferences p = NbPreferences.root().node("/org/netbeans/modules/autoupdate");//NOI18N if (preferenceChangeListener != null) { p.removePreferenceChangeListener (preferenceChangeListener); preferenceChangeListener = null; } }
Example 3
Source File: TestPreferences.java From netbeans with Apache License 2.0 | 5 votes |
public void testAddPreferenceChangeListener() throws BackingStoreException, InterruptedException { final Preferences pref = getPreferencesNode(); PreferenceChangeListener l = new PreferenceChangeListener() { public void preferenceChange(PreferenceChangeEvent evt) { synchronized (TestPreferences.class) { //assertionerrors cause deadlock here assertSame(pref, evt.getNode()); assertEquals("key", evt.getKey()); assertEquals(evt.getNewValue(),pref.get(evt.getKey(),null), evt.getNewValue()); TestPreferences.class.notifyAll(); } } }; pref.addPreferenceChangeListener(l); try { synchronized (TestPreferences.class) { pref.put("key","AddPreferenceChangeListener"); pref.flush(); TestPreferences.class.wait(); } synchronized (TestPreferences.class) { pref.remove("key"); pref.flush(); TestPreferences.class.wait(); } synchronized (TestPreferences.class) { pref.put("key","AddPreferenceChangeListener2"); pref.flush(); TestPreferences.class.wait(); } } finally { pref.removePreferenceChangeListener(l); } }