/** * Add a PropertyChangeListener to the listener list. * @param listener The listener to add. */ public void addPropertyChangeListener(PropertyChangeListener listener) { if ( propertyChangeSupport == null ) { propertyChangeSupport = new PropertyChangeSupport(this); } propertyChangeSupport.addPropertyChangeListener(listener); }
this.propertySupport = new PropertyChangeSupport(this); String oldName = this.name ; this.name = name ; propertySupport.firePropertyChange("name", oldName, name); propertySupport.addPropertyChangeListener(listener);
String oldValue = this.text; this.text = newValue; propChangeSupport.firePropertyChange(TEXT, oldValue, newValue); String oldValue = this.status; this.status = newValue; propChangeSupport.firePropertyChange(STATUS, oldValue, newValue); propChangeSupport.addPropertyChangeListener(listener);
/** Add a property change listener. * @param l the listener to add */ public final synchronized void addPropertyChangeListener(PropertyChangeListener l) { if (supp == null) { supp = new PropertyChangeSupport(this); } supp.addPropertyChangeListener(l); }
public class Animal { // Create PropertyChangeSupport to manage listeners and fire events. private final PropertyChangeSupport support = new PropertyChangeSupport(this); private int foo; // Provide delegating methods to add / remove listeners to / from the support class. public void addPropertyChangeListener(PropertyChangeListener l) { support.addPropertyChangeListener(l); } public void removePropertyChangeListener(PropertyChangeListener l) { support.removePropertyChangeListener(l); } // Simple example of how to fire an event when the value of 'foo' is changed. protected void setFoo(int foo) { if (this.foo != foo) { // Remember previous value, assign new value and then fire event. int oldFoo = this.foo; this.foo = foo; support.firePropertyChange("foo", oldFoo, this.foo); } } }
@Override public void actionPerformed(ActionEvent e) { spcSupport.firePropertyChange(BUTTON_PRESSED, null, guiBtnText); spcSupport.addPropertyChangeListener(listener);
public synchronized void addPropertyChangeListener(PropertyChangeListener l) { if (supp == null) { supp = new PropertyChangeSupport(this); } supp.addPropertyChangeListener(l); }
private static final long SLEEP_DELAY = 100; private int progress = 0; private PropertyChangeSupport pcs = new PropertyChangeSupport(this); pcs.firePropertyChange(evt); pcs.addPropertyChangeListener(listener);
MyState newValue = state; this.state = newValue; pcSupport.firePropertyChange(MyState.class.getName(), oldValue, newValue); Integer newValue = progress; this.progress = newValue; pcSupport.firePropertyChange(PROGRESS, oldValue, newValue); pcSupport.addPropertyChangeListener(listener);
/** Registers PropertyChangeListener to receive events. *@param listener The listener to register. */ public final void addPropertyChangeListener(PropertyChangeListener listener) { synchronized (internLock) { if (changeSupport == null) { changeSupport = new PropertyChangeSupport(this); } } changeSupport.addPropertyChangeListener(listener); }
public class Game { private PropertyChangeSupport pcs = new PropertyChangeSupport(this); ... public setSomeField(String field){ this.field = field; pcs.firePropertyChange("field", this.field, field); } public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener) { pcs.addPropertyChangeListener(propertyChangeListener); } ... }
/** Adds the specified property change listener to receive property * change events from this object. * @param l the property change listener */ public final void addPropertyChangeListener(PropertyChangeListener l) { boolean noListener; synchronized (getLock()) { // System.out.println ("added listener: " + l + " to: " + getClass ()); // NOI18N PropertyChangeSupport supp = (PropertyChangeSupport) getProperty(PROP_SUPPORT); if (supp == null) { // System.out.println ("Creating support"); // NOI18N putProperty(PROP_SUPPORT, supp = new PropertyChangeSupport(this)); } noListener = !supp.hasListeners(null); supp.addPropertyChangeListener(l); } if (noListener) { addNotifySuper = false; addNotify(); if (!addNotifySuper) { // [PENDING] theoretical race condition for this warning if listeners are added // and removed very quickly from two threads, I guess, and addNotify() impl is slow String msg = "You must call super.addNotify() from " + getClass().getName() + ".addNotify()"; // NOI18N err.warning(msg); } } }
/** Add a property change listener. * @param l the listener to add */ public final synchronized void addPropertyChangeListener(PropertyChangeListener l) { if (supp == null) { supp = new PropertyChangeSupport(this); } supp.addPropertyChangeListener(l); }
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { boolean first = false; if (support== null) { support = new PropertyChangeSupport(this); first = true; } support.addPropertyChangeListener(listener); if (first) { global.registerListener(type, this); } }
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { boolean first = false; if (support== null) { support = new PropertyChangeSupport(this); first = true; } support.addPropertyChangeListener(listener); if (first) { global.registerListener(key, this); } }
/** Adds the specified property change listener to receive property * change events from this object. * @param l the property change listener */ public final void addPropertyChangeListener(PropertyChangeListener l) { boolean noListener; synchronized (getLock()) { // System.out.println ("added listener: " + l + " to: " + getClass ()); // NOI18N PropertyChangeSupport supp = (PropertyChangeSupport) getProperty(PROP_SUPPORT); if (supp == null) { // System.out.println ("Creating support"); // NOI18N putProperty(PROP_SUPPORT, supp = new PropertyChangeSupport(this)); } noListener = !supp.hasListeners(null); supp.addPropertyChangeListener(l); } if (noListener) { addNotifySuper = false; addNotify(); if (!addNotifySuper) { // [PENDING] theoretical race condition for this warning if listeners are added // and removed very quickly from two threads, I guess, and addNotify() impl is slow String msg = "You must call super.addNotify() from " + getClass().getName() + ".addNotify()"; // NOI18N err.warning(msg); } } }
/** Add a <code>PropertyChangeListener</code> to the listener list. * @param l the listener to add */ public synchronized void addPropertyChangeListener(PropertyChangeListener l) { if (propertySupport == null) { propertySupport = new PropertyChangeSupport(this); } propertySupport.addPropertyChangeListener(l); }
/** * Registers a listener to be notified when some of the platform's properties * change */ public final void addPropertyChangeListener(PropertyChangeListener l) { synchronized (this) { if (supp == null) supp = new PropertyChangeSupport(this); } supp.addPropertyChangeListener(l); }
/** * Add a PropertyChangeListener to the listener list. * @param listener The listener to add. */ public void addPropertyChangeListener(PropertyChangeListener listener) { if ( propertyChangeSupport == null ) { propertyChangeSupport = new PropertyChangeSupport(this); } propertyChangeSupport.addPropertyChangeListener(listener); }
public void addPropertyChangeListener(PropertyChangeListener listener) { if (pcs == null) pcs = new PropertyChangeSupport(this); this.pcs.addPropertyChangeListener(listener); }