本文整理汇总了Java中java.beans.VetoableChangeSupport.addVetoableChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java VetoableChangeSupport.addVetoableChangeListener方法的具体用法?Java VetoableChangeSupport.addVetoableChangeListener怎么用?Java VetoableChangeSupport.addVetoableChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.VetoableChangeSupport
的用法示例。
在下文中一共展示了VetoableChangeSupport.addVetoableChangeListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public static void main(String[] args) {
CheckListener first = new CheckListener(false);
CheckListener second = new CheckListener(true);
CheckListener third = new CheckListener(false);
VetoableChangeSupport vcs = new VetoableChangeSupport(Test6630275.class);
vcs.addVetoableChangeListener(first);
vcs.addVetoableChangeListener(PROPERTY, first);
vcs.addVetoableChangeListener(PROPERTY, second);
vcs.addVetoableChangeListener(PROPERTY, third);
try {
vcs.fireVetoableChange(PROPERTY, true, false);
} catch (PropertyVetoException exception) {
first.validate();
second.validate();
third.validate();
return; // expected exception
}
throw new Error("exception should be thrown");
}
示例2: main
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public static void main(String[] args) {
CheckListener first = new CheckListener();
VetoListener second = new VetoListener();
CheckListener third = new CheckListener();
VetoableChangeSupport vcs = new VetoableChangeSupport(Test4425885.class);
vcs.addVetoableChangeListener(PROPERTY, first);
vcs.addVetoableChangeListener(PROPERTY, second);
vcs.addVetoableChangeListener(PROPERTY, third);
try {
vcs.fireVetoableChange(PROPERTY, 0, 1);
} catch (PropertyVetoException exception) {
if (first.odd)
throw new Error("no undo for the first listener", exception);
if (third.odd)
throw new Error("no undo for the third listener", exception);
return; // expected exception
}
throw new Error("exception should be thrown");
}
示例3: testRemoveVetoableChangeListenerVetoableChangeListener_all_more_diff
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testRemoveVetoableChangeListenerVetoableChangeListener_all_more_diff() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
VetoableChangeListener proxy2 = EventHandler.create(
VetoableChangeListener.class, source, "getText");
String propertyName = "label";
support.addVetoableChangeListener(proxy);
support.addVetoableChangeListener(proxy2);
assertTrue(support.hasListeners(propertyName));
assertEquals(2, support.getVetoableChangeListeners().length);
support.removeVetoableChangeListener(proxy);
assertTrue(support.hasListeners(propertyName));
assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
assertEquals(1, support.getVetoableChangeListeners().length);
assertEquals(proxy2, support.getVetoableChangeListeners()[0]);
}
示例4: testFireVetoableChangeStringbooleanboolean_twoListeners
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testFireVetoableChangeStringbooleanboolean_twoListeners()
throws PropertyVetoException {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
VetoableChangeListener proxy2 = EventHandler.create(
VetoableChangeListener.class, source, "increaseTop");
support.addVetoableChangeListener(proxy);
support.addVetoableChangeListener(proxy2);
support.fireVetoableChange("label", true, false);
assertEquals("called", source.getText());
assertEquals(1, source.getTop());
}
示例5: testAddVetoableChangeListenerByPropertyName
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
/**
* The test checks the method add() for property specified
*/
public void testAddVetoableChangeListenerByPropertyName() {
VetoableChangeSupport vcs = new VetoableChangeSupport("bean1");
VetoableChangeListener vcl = new VetoableChangeListener() {
public void vetoableChange(PropertyChangeEvent pce) {
}
};
vcs.addVetoableChangeListener("property1", vcl);
VetoableChangeListener[] vcls = vcs
.getVetoableChangeListeners("property1");
assertNotNull("Returned listeners is null.", vcls);
assertEquals(1, vcls.length);
assertEquals(vcl, vcls[0]);
}
示例6: testRemoveVetoableChangeListenerStringVetoableChangeListener_property_diff
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testRemoveVetoableChangeListenerStringVetoableChangeListener_property_diff() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
VetoableChangeListener proxy2 = EventHandler.create(
VetoableChangeListener.class, source, "getText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
support.addVetoableChangeListener(propertyName, proxy2);
assertTrue(support.hasListeners(propertyName));
assertEquals(2, support.getVetoableChangeListeners(propertyName).length);
support.removeVetoableChangeListener(propertyName, proxy);
assertTrue(support.hasListeners(propertyName));
assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
assertEquals(1, support.getVetoableChangeListeners().length);
assertSame(proxy2, support.getVetoableChangeListeners(propertyName)[0]);
}
示例7: testFireVetoableChangePropertyChangeEvent_property
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testFireVetoableChangePropertyChangeEvent_property()
throws PropertyVetoException {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
PropertyChangeEvent event = new PropertyChangeEvent(source, "label",
"Label: old", "Label: new");
support.fireVetoableChange(event);
assertEquals("called", source.getText());
}
示例8: testRemoveVetoableChangeListenerStringVetoableChangeListener_property_more
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testRemoveVetoableChangeListenerStringVetoableChangeListener_property_more() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
support.addVetoableChangeListener(propertyName, proxy);
assertTrue(support.hasListeners(propertyName));
assertEquals(2, support.getVetoableChangeListeners(propertyName).length);
support.removeVetoableChangeListener(propertyName, proxy);
assertTrue(support.hasListeners(propertyName));
assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
assertEquals(1, support.getVetoableChangeListeners().length);
}
示例9: testAddVetoableChangeListenerVetoableChangeListener
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testAddVetoableChangeListenerVetoableChangeListener() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
support.addVetoableChangeListener(proxy);
assertTrue(support.hasListeners("label"));
assertTrue(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners("label");
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(1, listeners1.length);
assertEquals(0, listeners2.length);
assertEquals(0, listeners3.length);
assertSame(proxy, listeners1[0]);
}
示例10: testAddVetoableChangeListenerStringVetoableChangeListener_property_invalid
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testAddVetoableChangeListenerStringVetoableChangeListener_property_invalid() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label_invalid";
support.addVetoableChangeListener(propertyName, proxy);
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners("label_invalid");
assertEquals(1, listeners1.length);
assertEquals(1, listeners2.length);
assertEquals("label_invalid",
((VetoableChangeListenerProxy) listeners1[0]).getPropertyName());
assertSame(proxy, listeners2[0]);
assertFalse(support.hasListeners("label"));
}
示例11: main
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public static void main(String[] args) throws PropertyVetoException {
TestEquals one = new TestEquals(1);
TestEquals two = new TestEquals(2);
Object source = TestEquals.class;
VetoableChangeSupport vcs = new VetoableChangeSupport(source);
vcs.addVetoableChangeListener(PROPERTY, one);
vcs.addVetoableChangeListener(PROPERTY, two);
PropertyChangeEvent event = new PropertyChangeEvent(source, PROPERTY, one, two);
vcs.fireVetoableChange(event);
test(one, two, 1); // only one check
vcs.fireVetoableChange(PROPERTY, one, two);
test(one, two, 2); // because it invokes fireVetoableChange(PropertyChangeEvent)
}
示例12: testFireVetoableChangeStringbooleanboolean_property
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testFireVetoableChangeStringbooleanboolean_property()
throws PropertyVetoException {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
support.addVetoableChangeListener("label", proxy);
support.fireVetoableChange("label", true, false);
assertEquals("called", source.getText());
}
示例13: testFireVetoableChangeStringintint_listener
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testFireVetoableChangeStringintint_listener()
throws PropertyVetoException {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
support.addVetoableChangeListener("label", proxy);
support.fireVetoableChange("label", 1, 2);
assertEquals("called", source.getText());
}
示例14: testAddVetoableChangeListenerVetoableChangeListener_TwoDifferent
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testAddVetoableChangeListenerVetoableChangeListener_TwoDifferent() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
VetoableChangeListener proxy2 = EventHandler.create(
VetoableChangeListener.class, source, "getText");
support.addVetoableChangeListener(proxy);
support.addVetoableChangeListener(proxy2);
assertTrue(support.hasListeners("label"));
assertTrue(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners("label");
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(2, listeners1.length);
assertEquals(0, listeners2.length);
assertEquals(0, listeners3.length);
for (VetoableChangeListener element : listeners1) {
assertTrue((proxy == element) || (proxy2 == element));
}
}
示例15: testFireVetoableChangeStringObjectObject_property_Null
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testFireVetoableChangeStringObjectObject_property_Null()
throws PropertyVetoException {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
support.addVetoableChangeListener(proxy);
support.fireVetoableChange(null, "Label: old", "Label: new");
assertEquals("called", source.getText());
}