Code example for PropertyChangeSupport

Methods: addPropertyChangeListenerfireIndexedPropertyChange

0
        sup.hasListeners(null);
    } 
 
    public void testFireIndexedPropertyChange() { 
        final Object src = new Object();
        PropertyChangeSupport pcs = new PropertyChangeSupport(src);
        pcs.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                assertEquals(src, evt.getSource());
                assertEquals(0, ((IndexedPropertyChangeEvent)evt).getIndex());
                assertEquals("one", evt.getOldValue());
                assertEquals("two", evt.getNewValue());
            } 
        }); 
 
        pcs.fireIndexedPropertyChange("foo", 0, "one", "two");
    } 
 
    /* 
     * Test the method firePropertyChange(String, Object, Object) with normal 
     * parameters, when there is no listeners. 
Stop searching for code, let great code find you!  Add Codota to your java IDE