import java.beans.*; public class TestBean { // an instance of PropertyChangeSupport to give all the hard work to protected PropertyChangeSupport butler = new PropertyChangeSupport(this); // the guts of the 'glitzyProperty' property protected int starValue; //------------------------------------------------------------------- // Constructor //------------------------------------------------------------------- public TestBean() { starValue = 99; // give our property a dummy starting value } //------------------------------------------------------------------- // set()/get() for 'glitzyProperty' property //------------------------------------------------------------------- public void setGlitzyProperty(int newValue) { int oldValue = starValue; starValue = newValue; butler.firePropertyChange("glitzyProperty", new Integer(oldValue), new Integer(newValue)); } public int getGlitzyProperty() { return starValue; } //------------------------------------------------------------------- // the listener (de)registration methods are trivial: just let the // PropertyChangeSupport class do all the hard work for us. //------------------------------------------------------------------- public void addPropertyChangeListener(PropertyChangeListener listener) { butler.addPropertyChangeListener(listener); } public void removePropertyChangeListener(PropertyChangeListener listener) { butler.removePropertyChangeListener(listener); } } // End of Class TestBean