当前位置: 首页>>代码示例>>Java>>正文


Java VetoableChangeSupport类代码示例

本文整理汇总了Java中java.beans.VetoableChangeSupport的典型用法代码示例。如果您正苦于以下问题:Java VetoableChangeSupport类的具体用法?Java VetoableChangeSupport怎么用?Java VetoableChangeSupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VetoableChangeSupport类属于java.beans包,在下文中一共展示了VetoableChangeSupport类的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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:Test6630275.java

示例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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:Test4425885.java

示例3: testRemoveVetoableChangeListenerVetoableChangeListener_all_null

import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerVetoableChangeListener_all_null() {
    MockSource source = new MockSource();
    VetoableChangeSupport support = new VetoableChangeSupport(source);

    VetoableChangeListener proxy = EventHandler.create(
            VetoableChangeListener.class, source, "setText");

    String propertyName = "label";
    support.addVetoableChangeListener(null);

    assertFalse(support.hasListeners(propertyName));
    assertEquals(0, support.getVetoableChangeListeners().length);

    support.removeVetoableChangeListener(proxy);

    assertFalse(support.hasListeners(propertyName));
    assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
    assertEquals(0, support.getVetoableChangeListeners().length);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:VetoableChangeSupportTest.java

示例4: testRemoveVetoableChangeListenerVetoableChangeListener_null

import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerVetoableChangeListener_null() {
    MockSource source = new MockSource();
    VetoableChangeSupport support = new VetoableChangeSupport(source);

    VetoableChangeListener proxy = EventHandler.create(
            VetoableChangeListener.class, source, "setText");

    String propertyName = "label";
    support.addVetoableChangeListener(proxy);

    assertTrue(support.hasListeners(propertyName));
    assertEquals(1, support.getVetoableChangeListeners().length);

    support.removeVetoableChangeListener(null);

    assertTrue(support.hasListeners(propertyName));
    assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
    assertEquals(1, support.getVetoableChangeListeners().length);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:VetoableChangeSupportTest.java

示例5: 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"));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:VetoableChangeSupportTest.java

示例6: testAddVetoableChangeListenerVetoableChangeListener_null

import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testAddVetoableChangeListenerVetoableChangeListener_null() {
    MockSource source = new MockSource();
    VetoableChangeSupport support = new VetoableChangeSupport(source);
    support.addVetoableChangeListener(null);

    assertFalse(support.hasListeners("label"));
    assertFalse(support.hasListeners("text"));

    VetoableChangeListener[] listeners1 = support
            .getVetoableChangeListeners();
    VetoableChangeListener[] listeners2 = support
            .getVetoableChangeListeners("label");
    VetoableChangeListener[] listeners3 = support
            .getVetoableChangeListeners("text");

    assertEquals(0, listeners1.length);
    assertEquals(0, listeners2.length);
    assertEquals(0, listeners3.length);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:VetoableChangeSupportTest.java

示例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());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:VetoableChangeSupportTest.java

示例8: testRemoveVetoableChangeListenerVetoableChangeListener_all

import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerVetoableChangeListener_all() {
    MockSource source = new MockSource();
    VetoableChangeSupport support = new VetoableChangeSupport(source);

    VetoableChangeListener proxy = EventHandler.create(
            VetoableChangeListener.class, source, "setText");

    String propertyName = "label";
    support.addVetoableChangeListener(proxy);
    assertTrue(support.hasListeners(propertyName));

    support.removeVetoableChangeListener(proxy);
    assertFalse(support.hasListeners(propertyName));
    assertEquals(0, support.getVetoableChangeListeners(propertyName).length);
    assertEquals(0, support.getVetoableChangeListeners().length);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:VetoableChangeSupportTest.java

示例9: testFireVetoableChangeStringbooleanboolean_listener_Property_invalid

import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testFireVetoableChangeStringbooleanboolean_listener_Property_invalid()
        throws PropertyVetoException {
    MockSource source = new MockSource();
    VetoableChangeSupport support = new VetoableChangeSupport(source);

    VetoableChangeListener proxy = EventHandler.create(
            VetoableChangeListener.class, source, "label", "source.text");
    support.addVetoableChangeListener("label", proxy);
    String newText = "new Text value";
    source.setText(newText);

    support.fireVetoableChange("text", true, false);
    assertEquals("label.default", source.getLabel());

    support.fireVetoableChange("label_invalid", true, false);
    assertEquals("label.default", source.getLabel());

    support.fireVetoableChange("label", true, false);
    assertEquals(newText, source.getLabel());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:VetoableChangeSupportTest.java

示例10: testRemoveVetoableChangeListenerStringVetoableChangeListener_propertyName_Invalid

import java.beans.VetoableChangeSupport; //导入依赖的package包/类
public void testRemoveVetoableChangeListenerStringVetoableChangeListener_propertyName_Invalid() {
    MockSource source = new MockSource();
    VetoableChangeSupport support = new VetoableChangeSupport(source);

    VetoableChangeListener proxy = EventHandler.create(
            VetoableChangeListener.class, source, "setText");

    String propertyName = "label";
    support.addVetoableChangeListener(propertyName, proxy);
    assertTrue(support.hasListeners(propertyName));

    support.removeVetoableChangeListener(propertyName + "_invalid", proxy);
    assertTrue(support.hasListeners(propertyName));
    assertEquals(1, support.getVetoableChangeListeners(propertyName).length);
    assertEquals(1, support.getVetoableChangeListeners().length);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:VetoableChangeSupportTest.java

示例11: 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]);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:VetoableChangeSupportTest.java

示例12: 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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:VetoableChangeSupportTest.java

示例13: 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]);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:VetoableChangeSupportTest.java

示例14: addVetoableChangeListener

import java.beans.VetoableChangeSupport; //导入依赖的package包/类
/**
 * Adds a <code>VetoableChangeListener</code> to the listener list.
 * The listener is registered for all properties.
 *
 * @param listener  the <code>VetoableChangeListener</code> to be added
 */
public synchronized void addVetoableChangeListener(VetoableChangeListener listener) {
    if (vetoableChangeSupport == null) {
        vetoableChangeSupport = new java.beans.VetoableChangeSupport(this);
    }
    vetoableChangeSupport.addVetoableChangeListener(listener);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:JComponent.java

示例15: 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)
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:TestEquals.java


注:本文中的java.beans.VetoableChangeSupport类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。