Package javax.swing.event

Examples of javax.swing.event.EventListenerList


  private static class L2 extends L1 {};
  private static class L3 extends L1 {};

  public void test(TestHarness harness)
  {
    EventListenerList ell = new EventListenerList();
    L1 l1 = new L1();
    L2 l2 = new L2();
    L3 l3_1 = new L3();
    L3 l3_2 = new L3();

    // Check #1.
    harness.check(ell.getListenerCount(), 0);

    // Check #2.
    harness.check(ell.getListenerCount(L1.class), 0);

    // Check #3: null argument (Classpath bug #7099).
    harness.check(ell.getListenerCount(null), 0);

    // Check #4: Class that does not implement EventListener.
    harness.check(ell.getListenerCount(String.class), 0);

    // Check #5.
    ell.add(L1.class, l1);
    ell.add(L2.class, l2);
    ell.add(L1.class, l3_1);
    ell.add(L3.class, l3_2);
    harness.check(ell.getListenerCount(), 4);

    // Check #6.
    harness.check(ell.getListenerCount(L1.class), 2);

    // Check #7.
    harness.check(ell.getListenerCount(L2.class), 1);

    // Check #8.
    harness.check(ell.getListenerCount(L3.class), 1);
  }
View Full Code Here


  };


  public void test(TestHarness harness)
  {
    EventListenerList ell = new EventListenerList();
    EventListener l1 = new L();
    L l2 = new L();
    Object[] list;

    // Check #1.
    list = ell.getListenerList();
    harness.check(list.length, 0);

    // Check #2.
    ell.add(EventListener.class, l1);
    ell.add(L.class, l2);
    list = ell.getListenerList();
    harness.check(list.length, 4);

    // Check #3.
    harness.check(list[0] == EventListener.class);

    // Check #4.
    harness.check(list[1] == l1);

    // Check #5.
    harness.check(list[2] == L.class);

    // Check #6.
    harness.check(list[3] == l2);

    // Check #7: Same array returned upon each invocation.
    harness.check(ell.getListenerList() == list);

    // Check #8.
    ell.remove(EventListener.class, l1);
    list = ell.getListenerList();
    harness.check(list.length, 2);

    // Check #9.
    harness.check(list[0] == L.class);
View Full Code Here

  {
  };

  public void test(TestHarness harness)
  {
    EventListenerList ell = new EventListenerList();
    EventListener l1 = new L();
    L l2 = new L();
    Object[] list;
    Throwable caught;

    // Check #1.
    ell.add(EventListener.class, l1);
    ell.add(L.class, l2);
    ell.remove(EventListener.class, l1);
    list = ell.getListenerList();
    harness.check(list.length, 2);

    // Check #2.
    // Classpath bug #7105.
    harness.check(list[0] == L.class);

    // Check #3.
    // Classpath bug #7105.
    harness.check(list[1] == l2);

    // Check #4: Remove something not in the list.
    ell.remove(EventListener.class, l2);
    list = ell.getListenerList();
    harness.check(list.length, 2);

    // Check #5: remove(null, foo)
    // Classpath bug #7105.
    caught = null;
    try
      {
        ell.remove(null, l2);
      }
    catch (Exception ex)
      {
        caught = ex;
      }
    harness.check(caught instanceof NullPointerException);

    // Check #6: remove(foo, null)
    caught = null;
    try
      {
        ell.remove(EventListener.class, null);
      }
    catch (Exception ex)
      {
        caught = ex;
      }
    harness.check(caught, null);

    // Check #7: remove(null, null)
    caught = null;
    try
      {
        ell.remove(null, null);
      }
    catch (Exception ex)
      {
        caught = ex;
      }
    harness.check(caught, null);

  /* Doesn't compile with 1.5
    // Check #8: Removing non-instance.
    // Classpath bug #7105.
    caught = null;
    try
      {
        ell.remove(L2.class, l2);
      }
    catch (Exception ex)
      {
        caught = ex;
      }
    harness.check(caught instanceof IllegalArgumentException);
  */

    // Unsuccessful attempts should not change the list.
    list = ell.getListenerList();   
    harness.check(list.length, 2);   // Check #9.
    harness.check(list[0], L.class); // Check #10. Classpath bug #7105.
    harness.check(list[1] == l2);    // Check #11. Classpath bug #7105.

    // Check #12: Removal of doubly registered listener.
    ell = new EventListenerList();
    ell.add(L.class, l2);
    ell.add(L.class, l2);
    ell.remove(L.class, l2);
    harness.check(ell.getListenerList().length, 2);
  }
View Full Code Here

  {
  };

  public void test(TestHarness harness)
  {
    EventListenerList ell = new EventListenerList();
    L1 l1a = new L1();
    L1 l1b = new L1();
    L2 l2 = new L2();
    L3 l3 = new L3();
    EventListener[] list;
    Throwable caught;

    ell.add(EventListener.class, l1a);
    ell.add(L2.class, l2);
    ell.add(L3.class, l3);
    ell.add(L1.class, l1b);
    list = ell.getListeners(L1.class);
   
    harness.check(list.length, 1); // #1.
    harness.check(list[0] == l1b); // #2.
    harness.check(list.getClass().getComponentType(), L1.class); // #3.

    list = ell.getListeners(L2.class);
    harness.check(list.length, 1); // #4.
    harness.check(list[0] == l2); // #5.
    harness.check(list.getClass().getComponentType(), L2.class); // #6.

    list = ell.getListeners(L3.class);
    harness.check(list.length, 1); // #7.
    harness.check(list[0] == l3); // #8.
    harness.check(list.getClass().getComponentType(), L3.class); // #9.

    list = ell.getListeners(EventListener.class);
    harness.check(list.length, 1); // #10.
    harness.check(list[0] == l1a); // #11.
    harness.check(list.getClass().getComponentType(),
                  EventListener.class); // #12.

    harness.check(ell.getListeners(L4.class).length, 0); // #13.

    // Check #14.
    caught = null;
    try
      {
        ell.getListeners(null);
      }
    catch (Exception ex)
      {
        caught = ex;
      }
View Full Code Here

  public void addReportModelListener(final ReportModelListener listener)
  {
    if (eventListeners == null)
    {
      eventListeners = new EventListenerList();
    }
    this.eventListeners.add(ReportModelListener.class, listener);
  }
View Full Code Here

    editorPanel = new JPanel(new BorderLayout());
    editorPanel.add(nameField, BorderLayout.CENTER);
    editorPanel.add(typePopupButton, BorderLayout.EAST);

    eventListenerList = new EventListenerList();
  }
View Full Code Here

  private Throwable error;
  private NameGenerator bodyNameGenerator;

  protected AbstractReportProcessTask()
  {
    this.listeners = new EventListenerList();
  }
View Full Code Here

  private Preferences properties;
  private static final File[] EMPTY_FILES = new File[0];

  public RecentFilesModel()
  {
    eventListeners = new EventListenerList();
    properties = Preferences.userRoot().node("org/pentaho/reporting/designer/recent-files"); // NON-NLS
  }
View Full Code Here

  private RepositoryTreeRoot root;
  private static final String[] EMPTY_FILTER = new String[0];

  public RepositoryTreeModel()
  {
    this.listenerList = new EventListenerList();
    this.filters = EMPTY_FILTER;
    this.showFoldersOnly = true;
    this.root = new RepositoryTreeRoot();
  }
View Full Code Here

  private Preferences properties;
  private static final String[] EMPTY_FORMATS = new String[0];

  public NumberFormatModel()
  {
    eventListeners = new EventListenerList();
    properties = Preferences.userRoot().node("org/pentaho/reporting/designer/numberformats"); // NON-NLS
  }
View Full Code Here

TOP

Related Classes of javax.swing.event.EventListenerList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.