package com.wiley.compbooks.brose.chapter3.hello;

import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class Applet
    extends java.applet.Applet
    implements ActionListener 
{

    private GoodDay goodDay;
    private Button helloWorldButton;
    private TextField textField;

    public void init() {

        helloWorldButton = new Button("Invoke method");
        helloWorldButton.setFont(new Font("Helvetica",
                                          Font.BOLD, 20));
	helloWorldButton.setActionCommand("invoke");
	helloWorldButton.addActionListener( (ActionListener) this );

        textField = new TextField();
        textField.setEditable(false);
        textField.setFont(new Font("Helvetica", Font.BOLD, 14));
        
        setLayout( new GridLayout(2,1));
        add( helloWorldButton );
        add( textField );

        // create object
        goodDay = new GoodDayImpl("San Mateo");
    }

    public void actionPerformed( ActionEvent e ) {

        if( e.getActionCommand().equals("invoke") ) {

            // invoke the operation
            textField.setText( goodDay.hello() );
        }
    }
}
