當前位置: 首頁>>代碼示例>>Java>>正文


Java PropertyChangeSupport類代碼示例

本文整理匯總了Java中java.beans.PropertyChangeSupport的典型用法代碼示例。如果您正苦於以下問題:Java PropertyChangeSupport類的具體用法?Java PropertyChangeSupport怎麽用?Java PropertyChangeSupport使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PropertyChangeSupport類屬於java.beans包,在下文中一共展示了PropertyChangeSupport類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
public static void main(String[] args) {
    TestEquals one = new TestEquals(1);
    TestEquals two = new TestEquals(2);

    Object source = TestEquals.class;
    PropertyChangeSupport pcs = new PropertyChangeSupport(source);
    pcs.addPropertyChangeListener(PROPERTY, one);
    pcs.addPropertyChangeListener(PROPERTY, two);

    PropertyChangeEvent event = new PropertyChangeEvent(source, PROPERTY, one, two);
    pcs.firePropertyChange(event);
    test(one, two, 1); // only one check
    pcs.firePropertyChange(PROPERTY, one, two);
    test(one, two, 2); // because it invokes firePropertyChange(PropertyChangeEvent)
    pcs.fireIndexedPropertyChange(PROPERTY, 1, one, two);
    test(one, two, 2); // because it invokes firePropertyChange(PropertyChangeEvent)
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:TestEquals.java

示例2: OutputNode

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
/**
 * Creates a new output node
 */
public OutputNode() {
    this.connector = new NodeConnector(this);
    propertyChangeSupport = new PropertyChangeSupport(this);
    listenerList = new EventListenerList();
    img = null;
}
 
開發者ID:VISNode,項目名稱:VISNode,代碼行數:10,代碼來源:OutputNode.java

示例3: ForwardingLibraryImplementation

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
/**
 * Creates a new {@link ForwardingLibraryImplementation}.
 * @param delegate the delegate
 */
public ForwardingLibraryImplementation(@NonNull final LibraryImplementation delegate) {
    Parameters.notNull("delegate", delegate);   //NOI18N
    this.delegate = delegate;
    this.support = new PropertyChangeSupport(this);
    this.listener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            ForwardingLibraryImplementation.this.support.firePropertyChange(
                evt.getPropertyName(),
                evt.getOldValue(),
                evt.getNewValue());
        }
    };
    this.delegate.addPropertyChangeListener(WeakListeners.propertyChange(
        this.listener,
        this.delegate));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:ForwardingLibraryImplementation.java

示例4: OpenProjectList

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
OpenProjectList() {
    LOAD = new LoadOpenProjects(0);
    openProjects = new ArrayList<Project>();
    openProjectsModuleInfos = new HashMap<ModuleInfo, List<Project>>();
    infoListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evn) {
            if (ModuleInfo.PROP_ENABLED.equals(evn.getPropertyName())) {
                checkModuleInfo((ModuleInfo)evn.getSource());
            }
        }
    };
    pchSupport = new PropertyChangeSupport( this );
    recentProjects = new RecentProjectList(10); // #47134
    recentTemplates = new ArrayList<String>();
    projectGroupSupport = new ArrayList<ProjectGroupChangeListener>();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:OpenProjectList.java

示例5: MapDataAdapter

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
/**
 * Creates a new MapDataAdapter from the given list of objects.
 *
 * @param dataCollectionName the name given to the objects group
 * @param dataObjects list containing data to be aggregated as children
 * @param valueFunction the function used to calculated the objects value
 * @param nameFunction the function used to get the objects name
 */
public MapDataAdapter(String dataCollectionName, List<T> dataObjects, DataValueFunction<T> valueFunction, DataNameFunction<T> nameFunction) {
    if (dataObjects == null) {
        throw new IllegalArgumentException("dataObjects should not be null");
    }
    if (valueFunction == null) {
        throw new IllegalArgumentException(VALUE_F_NULL_MESSAGE);
    }
    propertyChangeSupport = new PropertyChangeSupport(MapDataAdapter.this);
    dataType = DataType.NODE;
    name = dataCollectionName;
    dataValueFunction = valueFunction;
    dataNameFunction = nameFunction;
    dataObject = null;
    dataAdapters = new LinkedList<>();
    dataObjectList = new LinkedList<>(dataObjects);
    dataObjectList.forEach(o -> dataAdapters.add(new MapDataAdapter<>(o, valueFunction, nameFunction)));
    recalculate();
    lastNotifiedValue = value;
}
 
開發者ID:PtitNoony,項目名稱:FxTreeMap,代碼行數:28,代碼來源:MapDataAdapter.java

示例6: ProgressFrame

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
/** Creates new form ProgressFrame */
public ProgressFrame() {
    propertySupport = new PropertyChangeSupport(this);
    
    initComponents ();
    this.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_ProgressFrameTabA11yDesc"));  // NOI18N
    okButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_CancelButtonA11yDesc"));  // NOI18N
    
    progressHandle = ProgressHandleFactory.createHandle(null);
    progressComponent = ProgressHandleFactory.createProgressComponent(progressHandle);
    progressPanel.add(progressComponent);
    progressHandle.start();

    javax.swing.ImageIcon ideIcon = new javax.swing.ImageIcon("/org/netbeans/core/resources/frames/ide.gif"); //NOI18N
    setIconImage(ideIcon.getImage());

    java.awt.Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setSize(380, 150);
    setLocation(dim.width/2 - 190, dim.height/2 - 80);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:ProgressFrame.java

示例7: JPDADebuggerImpl

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
public JPDADebuggerImpl (ContextProvider lookupProvider) {
    this.lookupProvider = lookupProvider;
    
    Properties p = Properties.getDefault().getProperties("debugger.options.JPDA");
    int stepResume = p.getInt("StepResume", (SINGLE_THREAD_STEPPING) ? 1 : 0);
    suspend = (stepResume == 1) ? SUSPEND_EVENT_THREAD : SUSPEND_ALL;

    pcs = new PropertyChangeSupport (this);
    List l = lookupProvider.lookup (null, DebuggerEngineProvider.class);
    int i, k = l.size ();
    for (i = 0; i < k; i++) {
        if (l.get (i) instanceof JavaEngineProvider) {
            javaEngineProvider = (JavaEngineProvider) l.get (i);
        }
    }
    if (javaEngineProvider == null) {
        throw new IllegalArgumentException
            ("JavaEngineProvider have to be used to start JPDADebugger!");
    }
    languages = new HashSet<String>();
    languages.add ("Java");
    threadsTranslation = ObjectTranslation.createThreadTranslation(this);
    localsTranslation = ObjectTranslation.createLocalsTranslation(this);
    this.expressionPool = new ExpressionPool();
    io = new DebuggerConsoleIO(this, lookupProvider);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:JPDADebuggerImpl.java

示例8: MainProjectManager

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
@java.lang.SuppressWarnings("LeakingThisInConstructor")
private MainProjectManager () {
    pcs = new PropertyChangeSupport (this);
    a = ProjectSensitiveActions.projectSensitiveAction (
        this, "x", null
    );
    OpenProjects.getDefault().addPropertyChangeListener(this);
    currentProject = new WeakReference<Project>(OpenProjects.getDefault().getMainProject());
    isMainProject = currentProject.get() != null;
    a.addPropertyChangeListener(this); // I'm listening on it so that I get enable() called.
    SwingUtilities.invokeLater(new Runnable() {
        public @Override void run() {
            a.isEnabled();
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:MainProjectManager.java

示例9: AbstractNbTaskWrapper

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
/** PRIVATE TASK ATTRIBUTES **/

    public AbstractNbTaskWrapper (NbTask task) {
        this.task = task;
        this.repositoryDataRef = new SoftReference<TaskData>(null);
        support = new PropertyChangeSupport(this);
        repositoryTaskDataLoaderTask = RP.create(new Runnable() {
            @Override
            public void run () {
                loadRepositoryTaskData();
            }
        });
        MylynSupport mylynSupp = MylynSupport.getInstance();
        taskDataListener = new TaskDataListenerImpl();
        mylynSupp.addTaskDataListener(WeakListeners.create(TaskDataListener.class, taskDataListener, mylynSupp));
        taskListener = new TaskListenerImpl();
        task.addNbTaskListener(WeakListeners.create(NbTaskListener.class, taskListener, mylynSupp));
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:AbstractNbTaskWrapper.java

示例10: FxMapModel

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
public FxMapModel(FxTreeMap treeMap, MapData mapData, double width, double height) {
    modelData = mapData;
    mapItems = new LinkedList<>();
    propertyChangeSupport = new PropertyChangeSupport(FxMapModel.this);
    propertyChangeSupport.addPropertyChangeListener(treeMap);
    style = new TreeMapStyle();
    style.removePropertyChangeListener(FxMapModel.this);
    totalArea = width * height;
    modelData.getChildrenData().forEach(d -> {
        FxMapItem mapItem = new FxMapItem(FxMapModel.this, d);
        mapItems.add(mapItem);
    });
    modelData.addPropertyChangeListener(this::handleModelChange);
}
 
開發者ID:PtitNoony,項目名稱:FxTreeMap,代碼行數:15,代碼來源:FxMapModel.java

示例11: setUp

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    source = new Object();
    pcs = new PropertyChangeSupport(source);
    l = new MockPropertyChangeListener();
    pcs.addPropertyChangeListener(l);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:MockPropertyChangeListenerTest.java

示例12: firePropertyChange

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
/**
 * Fires a PropertyChangeEvent in response to a change in a bound property.
 * The event will be delivered to all registered PropertyChangeListeners.
 * No event will be delivered if oldValue and newValue are the same.
 *
 * @param propertyName the name of the property that has changed
 * @param oldValue the property's previous value
 * @param newValue the property's new value
 */
protected void firePropertyChange(String propertyName, Object oldValue,
                                  Object newValue)
{
    if (oldValue == newValue) {
        return;
    }
    PropertyChangeSupport changeSupport = this.changeSupport;
    if (changeSupport != null) {
        changeSupport.firePropertyChange(propertyName, oldValue, newValue);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:KeyboardFocusManager.java

示例13: firePropertyChange

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
/**
 * Support for reporting bound property changes for Object properties.
 * This method can be called when a bound property has changed and it will
 * send the appropriate PropertyChangeEvent to any registered
 * PropertyChangeListeners.
 *
 * @param propertyName the property whose value has changed
 * @param oldValue the property's previous value
 * @param newValue the property's new value
 */
protected void firePropertyChange(String propertyName,
                                  Object oldValue, Object newValue) {
    PropertyChangeSupport changeSupport;
    synchronized (getObjectLock()) {
        changeSupport = this.changeSupport;
    }
    if (changeSupport == null ||
        (oldValue != null && newValue != null && oldValue.equals(newValue))) {
        return;
    }
    changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:Component.java

示例14: addPropertyChangeListener

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
/** 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);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:SharedClassObject.java

示例15: removePropertyChangeListener

import java.beans.PropertyChangeSupport; //導入依賴的package包/類
/**
 * Removes the specified property change listener so that it
 * no longer receives property change events from this object.
 * @param         l     the property change listener
 */
public final void removePropertyChangeListener(PropertyChangeListener l) {
    boolean callRemoved;

    synchronized (getLock()) {
        PropertyChangeSupport supp = (PropertyChangeSupport) getProperty(PROP_SUPPORT);

        if (supp == null) {
            return;
        }

        boolean hasListener = supp.hasListeners(null);
        supp.removePropertyChangeListener(l);
        callRemoved = hasListener && !supp.hasListeners(null);
    }

    if (callRemoved) {
        putProperty(PROP_SUPPORT, null); // clean the PCS, see #25417
        removeNotifySuper = false;
        removeNotify();

        if (!removeNotifySuper) {
            String msg = "You must call super.removeNotify() from " + getClass().getName() + ".removeNotify()"; // NOI18N
            err.warning(msg);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:SharedClassObject.java


注:本文中的java.beans.PropertyChangeSupport類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。