1   // joi/1/lights/NextButtonListener.java                         
2   //                                                            
3   //                                                            
4   // Copyright 2003 Bill Campbell and Ethan Bolker                         
5                                                               
6   import java.awt.event.*;
7   
8   /**
9    * A NextButtonListener sends a "next" message to its
10   * Sequencer each time a button to which it is listening
11   * is pressed.
12   *
13   * @version 1
14   */
15  
16  public class NextButtonListener implements ActionListener
17  {
18      private Sequencer sequencer;
19      
20      /**
21       * Construct a listener that "listens for" a user's
22       * pressing the "Next" button.
23       *
24       * @param sequencer the Sequencer for the TrafficLight.
25       */
26  
27      public NextButtonListener( Sequencer sequencer )
28      {
29          this.sequencer = sequencer;
30      }
31  
32      /**
33       * The action performed when a push of the button is detected:
34       * send a next message to the Sequencer to advance it to
35       * its next state.
36       *
37       * @param event the event detected at the button.
38       */
39  
40      public void actionPerformed( ActionEvent event )
41      {
42          this.sequencer.next();
43      }
44  }
45