/*
 * TheController.java
 * burton rosenberg
 * 13 April 2004
 */

import java.awt.* ;
import javax.swing.* ;
import java.awt.event.* ;

class TheController extends JPanel implements ActionListener {

    JButton [] jba ;
    final static String [] BUTTON_LABEL = { "Square", "Circle", "Triangle"  } ;
    TheModel tm ;

    TheController( TheModel tm ) {

       this.tm = tm ;
       tm.setController(this) ;

       jba = new JButton[BUTTON_LABEL.length] ;
       for ( int i=0; i<jba.length; i++ ) {
          jba[i] = new JButton(BUTTON_LABEL[i]) ;
          add(jba[i]) ;
          (jba[i]).addActionListener(this) ;
       }
    }


    public void actionPerformed(ActionEvent ae) {

       JButton jb = (JButton) ae.getSource() ;
       for ( int i=0; i<jba.length; i++ ) {
          if ( jba[i]==jb ) tm.setShape(i) ;
       }

    }

}

