///      AWT Example

//      this would be an example of a one class view where java.awt.Frame is subclassed
//      directly

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

class JaysView extends Frame implements ActionListener,
                                        WindowListener  {

    private List theList_;
    private void theList(List aList){ theList_ = aList; }
    private List theList(){ return theList_; }

    JaysView(){
        super( "First View from Jay" );
        this.initialize();
    }

    public static void main(String alf[]){
        System.out.println("Start of main in Jay's View");

        JaysView v = new JaysView();
        v.show();
    }

    private void initialize(){

        this.setLayout(null);

        this.addWindowListener(this);

        MenuBar aMenuBar = new MenuBar();

        Menu aMenu = new Menu("System");
        MenuItem aMenuItem = new MenuItem("Exit");
        aMenuItem.addActionListener(this);
        aMenuItem.setActionCommand("Exit");
        aMenu.add(aMenuItem);
        aMenuBar.add(aMenu);

        aMenu = new Menu("Edit");
        aMenuItem = new MenuItem("Cut");
        aMenuItem.disable();
        aMenu.add(aMenuItem);
        aMenuItem = new MenuItem("Copy");
        aMenuItem.disable();
        aMenu.add(aMenuItem);
        aMenuItem = new MenuItem("Paste");
        aMenuItem.disable();
        aMenu.add(aMenuItem);

        aMenuBar.add(aMenu);

        this.setMenuBar(aMenuBar);

        Button aButton = new Button("Press Me");
        aButton.setSize( 70, 30 );
        aButton.setLocation( 50,280 );
        aButton.addActionListener(this);
        aButton.setActionCommand("Press Me Button");

        this.add( aButton );

        this.theList( new List() );
        this.theList().setSize( 140, 200 );
        this.theList().setLocation( 20,80 );
        this.add( this.theList() );

        Label aLabel = new Label("I am a Label.");
        aLabel.setSize( 120,20 );
        aLabel.setLocation( 20,50 );
        this.add( aLabel );


        this.setSize(200,320);
        this.setLocation(200,200);

    }
    public void actionPerformed(ActionEvent e){

        String s = e.getActionCommand();

        if(s.equals("Exit")){
            this.exit();
            return;
        }
        if(s.equals("Press Me Button")){

            this.theList().addItem( "\"Press Me\" put me here." );
            return;
        }
    }
    // support WindowListener interface
    public void windowActivated     (WindowEvent e){}
    public void windowClosed        (WindowEvent e){}
    public void windowClosing       (WindowEvent e){
       this.exit();
    }
    public void windowOpened        (WindowEvent e){}
    public void windowDeactivated   (WindowEvent e){}
    public void windowIconified     (WindowEvent e){}
    public void windowDeiconified   (WindowEvent e){}


    private void exit(){
        System.out.println("Shutting down Jay's View");
        this.dispose();
        System.exit(0);
    }

}