本文整理汇总了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)
}
示例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;
}
示例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));
}
示例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>();
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
});
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
}