ChainedActionListener.java :  » Testing » Unicorn » org » savarese » unicorn » ui » event » Java Open Source

Java Open Source » Testing » Unicorn 
Unicorn » org » savarese » unicorn » ui » event » ChainedActionListener.java
/*
 * $Id: ChainedActionListener.java 6115 2006-01-30 04:50:47Z dfs $
 *
 * Copyright 2004-2006 Daniel F. Savarese
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.savarese.org/software/ApacheLicense-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.savarese.unicorn.ui.event;

import java.awt.event.*;
import java.util.*;

/**
 * An implementation of {@link ChainedEventListener} to process
 * ActionEvents for chains of ActionListeners.
 */
public class ChainedActionListener
  extends ChainedEventListener<ActionListener, ActionEvent>
  implements ActionListener,
             ChainedEventListener.EventProcessor<ActionListener, ActionEvent>
{
  /**
   * Instantiates a ChainedActionListener using the specified
   * {@link ChainedEventListener.EventProcessor}.
   *
   * @param processor The{@link ChainedEventListener.EventProcessor}
   * to use to process ActionEvents.
   */
  public ChainedActionListener(EventProcessor<ActionListener, ActionEvent>
                               processor)
  {
    super(processor);
  }

  /**
   * Instantiates a ChainedActionListener using the same
   * ChainedActionListener as the event processor.
   */
  public ChainedActionListener() {
    this(null);
    _processor_ = this;
  }

  /**
   * Calls {@code listener.actionPerformed(event);}
   *
   * @param listener The ActionListener to receive the event.
   * @param event The ActionEvent to deliver.
   */
  public void processEvent(ActionListener listener, ActionEvent event) {
    listener.actionPerformed(event);
  }

  /**
   * Delivers an ActionEvent to the chain of ActionListeners.
   *
   * @param event The ActionEvent to deliver.
   */
  public void actionPerformed(ActionEvent event) {
    _processEvent_(event);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.