Example usage for java.awt Component addPropertyChangeListener

List of usage examples for java.awt Component addPropertyChangeListener

Introduction

In this page you can find the example usage for java.awt Component addPropertyChangeListener.

Prototype

public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) 

Source Link

Document

Adds a PropertyChangeListener to the listener list for a specific property.

Usage

From source file:org.objectstyle.cayenne.modeler.pref.ComponentGeometry.java

/**
 * Binds this preference object to synchronize its state with a given component
 * property.//w  w  w.  j a  v  a2  s . c  om
 */
public void bindIntProperty(final Component component, final String property, int defaultValue) {

    updateIntProperty(component, property, defaultValue);

    component.addPropertyChangeListener(property, new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent e) {
            Object value = e.getNewValue();
            setProperty(property, value != null ? value.toString() : null);
        }
    });
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ???????/*from w  ww.ja  v a 2s .com*/
 * 
 * @param name ???????null ???????????
 * @param target ?
 * @param action ?????????????
 * @param property ???????????? 
 * @return ??
 * @see PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
 */
public EventQuery change(String name, Object target, String action, String property) {
    PropertyChangeListener propertyChange = EventHandler.create(PropertyChangeListener.class, target, action,
            property, "propertyChange");
    for (Component child : list) {
        if (name != null) {
            child.addPropertyChangeListener(name, propertyChange);
        } else {
            child.addPropertyChangeListener(propertyChange);
        }
    }

    return this;
}