/*
 * TrafficFrame.java    2.0 97/07/07
 * Copyright (c) 1997, B. F. Caviness
 *
 * This software may be copied/modified for any non-commercial educational use.
 */


import java.awt.*;              // awt = abstract window toolbox

/**
 * A driver class for the component <code>class ChangeableTL</code> and its
 * methods.  This uses JDK 1.1 except for the method handleEvent.
 */


public class TrafficFrame extends Frame
{

 public static void main(String args[])	// Main method
 {
    new TrafficFrame("Traffic Light Display Window");
 }


 ChangeableTL greenLight = new ChangeableTL();	// Create green light for window
 ChangeableTL redLight = new ChangeableTL( Color.red );	// Create red light


 public TrafficFrame(String title)	// Constructor for container Frame
 {
    super(title);			// Create window w title
    setLayout(new BorderLayout());	// Specify layout mgr for frame.
					// Border layout is the default.
    setSize(600,300);			// Resize Window; units are pixels
    add("West",greenLight);		// Attach light canvas to frame
    add("East",redLight);		// Attach light canvas to frame
    show();				// Display window
 }


 public boolean handleEvent(Event e)	// Redefine event handler so
 {					// that window can be deleted.
    System.out.println("TrafficFrame.handleEvent: e = " + e);
    switch (e.id)				// Switch on kind of event
    {
       case Event.WINDOW_DESTROY:	// Terminate program and thus
          System.exit(0); return true;	// window
   
       default:				// Pass all other events to 
          return super.handleEvent(e);	// super class
  }
 }
}
