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


Java VetoableChangeSupport.addVetoableChangeListener方法代碼示例

本文整理匯總了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");
}
 
開發者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_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

示例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());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:18,代碼來源:VetoableChangeSupportTest.java

示例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]);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:19,代碼來源:VetoableChangeSupportTest.java

示例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]);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:24,代碼來源: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: 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

示例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]);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:25,代碼來源:VetoableChangeSupportTest.java

示例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"));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:VetoableChangeSupportTest.java

示例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)
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:16,代碼來源:TestEquals.java

示例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());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:13,代碼來源:VetoableChangeSupportTest.java

示例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());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:12,代碼來源:VetoableChangeSupportTest.java

示例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));
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:29,代碼來源:VetoableChangeSupportTest.java

示例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());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:12,代碼來源:VetoableChangeSupportTest.java


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