

import java.awt.*;
import java.util.*;
import java.awt.event.*;


//  Example for array of "non-booleans"!

 class Controller extends Frame implements WindowListener, MouseListener

   {

     private static Controller controller;
     private static final int STARTWIDTH = 600;  // Initial size of
     private static final int STARTHEIGHT = 500; //  window.
     private static int width;      //  current width of frame (pixels)
     private static int height;     //  current height of frame (pixels)

     private static AList list;
     private static int t=0;        // Counter for number of time steps.
     private static Graphics g;



     public static void main(String [] arguments) throws Exception
        {

          controller = new Controller();

          while(true)
            {

                 {
                   Thread.sleep(20);   //  Pause between screen updates
                   t++;                //  Time moves ahead
                   controller.advance_time(); //
                   controller.paint(g);    // Re-paint everything.
                  }
//                System.out.println(t);

            }
        }



     public Controller()
        {
           super("  Linked List Controller  ");  //  Create and name window
           setSize(STARTWIDTH,STARTHEIGHT); //  Set initial size
           setBackground(Color.yellow.brighter()); // Initial back. color
           setVisible(true);                //  Display it!b

           addWindowListener(this); //  Tell Java runner that this frame
           addMouseListener(this);  //   obj will handle Window events
                                    //   and mouse events, so give them
                                    //   to us!

           list = new AList();

           t= 0;                      //  Start timer at 0.
           g = getGraphics();


 		for(int i = 0; i < 10; i++)
            list.add(i);

        }

     public void paint(Graphics g)
        {
//         width = getWidth();   //  Window might have re-sized.  So get
//          height = getHeight();  //  latest dimensions.
          width = getSize().width;
          height = getSize().height;

          g.clearRect(0,0,300,300);  // Erase the
                                                         // entire active
                                                         //  area
          g.drawRect(0,0,300,300);  //  Draw borders

          list.paint(g);

         }



      private void advance_time()
         {



          }






  //  Methods needed to implement the "WindowListener" interface

     public void windowOpened(WindowEvent win_ev)  {}
     public void windowClosing(WindowEvent win_ev)  // Catches click on
                 {                                  //  the window's "X"
                  dispose();
                  }
     public void windowClosed(WindowEvent win_ev)   {}
     public void windowActivated(WindowEvent win_ev)  {}
     public void windowDeactivated(WindowEvent win_ev)  {}
     public void windowIconified(WindowEvent win_ev)  {}
     public void windowDeiconified(WindowEvent win_ev)  {}

  //  Methods needed to implement the "MouseListener" interface

     public void mouseClicked(MouseEvent me)
                  {

                  	int x = me.getX();
           			int y = me.getY();
                    System.out.println("mouse click at " +
                                       x + ", " + y);

                    }
     public void mouseEntered(MouseEvent me)  {}
     public void mouseExited(MouseEvent me)  {}
     public void mousePressed(MouseEvent me)
          {

            controller.paint(g);    // Re-paint everything.
          }
     public void mouseReleased(MouseEvent me)  {}

   }