Java 8 PreferenceChangeEvent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PreferenceChangeEvent class.

This code example shows how to use the following methods:getSource, getKey, getNewValue, getNode
        assertSame(Preferences.userRoot(), event.getSource());
    } 
 
    public void testConstructor() { 
        event = new PreferenceChangeEvent(Preferences.userRoot(), "key",
        "value"); 
        assertEquals("key", event.getKey());
        assertEquals("value", event.getNewValue());
        assertSame(Preferences.userRoot(), event.getNode());
        assertSame(Preferences.userRoot(), event.getSource());
    } 
 
    public void testSerialization() throws Exception { 
        event = new PreferenceChangeEvent(Preferences.userRoot(), "key",
        "value"); 
        try { 
            SerializationTest.copySerializable(event);
            fail("No expected NotSerializableException");
        } catch (NotSerializableException e) {
        } 
6
CodeRank
This code example shows how to use the following methods:
        super.setUp(); 
        l = new PreferenceChangeListenerImpl();
    } 
 
    public void testPreferenceChange() { 
        l.preferenceChange(new PreferenceChangeEvent(Preferences.userRoot(),
                "", "")); 
    } 
 
    public static class PreferenceChangeListenerImpl implements 
    PreferenceChangeListener {
        public void preferenceChange(PreferenceChangeEvent pce) {
        } 
 
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:getKey, getNewValue, getNode
This code example shows how to use the following methods:getKey, getNode
			AppPreferences.getPrefs().putBoolean(getIdentifier(), newVal);
		} 
	} 
 
	public void preferenceChange(PreferenceChangeEvent event) {
		Preferences prefs = event.getNode();
		String prop = event.getKey();
		String name = getIdentifier();
		if (prop.equals(name)) {
			boolean oldValue = value;
			boolean newValue = prefs.getBoolean(name, dflt);
			if (newValue != oldValue) {
				value = newValue;
				AppPreferences.firePropertyChange(name, oldValue, newValue);
			} 
		} 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:getKey, getNode
			AppPreferences.getPrefs().put(getIdentifier(), newValue);
		} 
	} 
 
	public void preferenceChange(PreferenceChangeEvent event) {
		Preferences prefs = event.getNode();
		String prop = event.getKey();
		String name = getIdentifier();
		if (prop.equals(name)) {
			String oldValue = value;
			String newValue = prefs.get(name, dflt);
			if (!isSame(oldValue, newValue)) {
				value = newValue;
				AppPreferences.firePropertyChange(name, oldValue, newValue);
			} 
		} 
	} 
	 
	private static boolean isSame(String a, String b) {
		return a == null ? b == null : a.equals(b);
5
CodeRank
This code example shows how to use the following methods:getKey, getNode
			AppPreferences.getPrefs().putDouble(getIdentifier(), newVal);
		} 
	} 
 
	public void preferenceChange(PreferenceChangeEvent event) {
		Preferences prefs = event.getNode();
		String prop = event.getKey();
		String name = getIdentifier();
		if (prop.equals(name)) {
			double oldValue = value;
			double newValue = prefs.getDouble(name, dflt);
			if (newValue != oldValue) {
				value = newValue;
				AppPreferences.firePropertyChange(name,
						Double.valueOf(oldValue), Double.valueOf(newValue));
			} 
		} 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:getKey, getNode
			AppPreferences.getPrefs().putInt(getIdentifier(), newVal);
		} 
	} 
 
	public void preferenceChange(PreferenceChangeEvent event) {
		Preferences prefs = event.getNode();
		String prop = event.getKey();
		String name = getIdentifier();
		if (prop.equals(name)) {
			int oldValue = value;
			int newValue = prefs.getInt(name, dflt);
			if (newValue != oldValue) {
				value = newValue;
				AppPreferences.firePropertyChange(name,
						Integer.valueOf(oldValue), Integer.valueOf(newValue));
			} 
		} 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:getNewValue
 
        AbstractPreferences pref = (AbstractPreferences) parent.node("mock");
 
        MockPreferenceChangeListener pl = new MockPreferenceChangeListener() {
            public void preferenceChange(PreferenceChangeEvent pce) {
                if (pce != null && pce.getNewValue().equals(Integer.toString(Integer.MAX_VALUE))) {
                    result = true;
                } 
                super.preferenceChange(pce);
            } 
        }; 
        pref.addPreferenceChangeListener(pl);
        try { 
            pref.putInt("key_int", Integer.MAX_VALUE);
            assertEquals(1, pl.getChanged());
            assertTrue(pl.getResult());
            pl.reset();
 
            pref.putInt("key_int", Integer.MAX_VALUE);
            assertEquals(1, pl.getChanged());
4
CodeRank
This code example shows how to use the following methods:getKey, getNode
        } 
    } 
 
    @Override 
    public void preferenceChange(PreferenceChangeEvent event) {
        Preferences prefs = event.getNode();
        String prop = event.getKey();
        String name = getIdentifier();
        if (prop.equals(name)) {
            boolean oldValue = value;
            boolean newValue = prefs.getBoolean(name, dflt);
            if (newValue != oldValue) {
                value = newValue;
                AppPreferences.firePropertyChange(name, oldValue, newValue);
            } 
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:getKey, getNode
        } 
    } 
 
    @Override 
    public void preferenceChange(PreferenceChangeEvent event) {
        Preferences prefs = event.getNode();
        String prop = event.getKey();
        String name = getIdentifier();
        if (prop.equals(name)) {
            String oldValue = value;
            String newValue = prefs.get(name, dflt);
            if (!isSame(oldValue, newValue)) {
                value = newValue;
                AppPreferences.firePropertyChange(name, oldValue, newValue);
            } 
        } 
    } 
 
    private static boolean isSame(String a, String b) {
        return a == null ? b == null : a.equals(b);
4
CodeRank
See Code Examples for Java 8 PreferenceChangeEvent Methods: