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

    // Display a labelled text area and a submit button.
public class CommentsForm extends Frame
                                implements ActionListener {
    public CommentsForm(){
        final int width = 450, height = 250;
        setSize(width,height);
        setBackground(Color.white);

        // Place a centred label at the top.
        Label welcome = new Label("We welcome your comments.",Label.CENTER);
        add(welcome,"North");

        // A central TextArea for comments.
        // How many characters are allowed to be entered.
        final int numRows = 10, numCols = 40;
        Label nameLabel = new Label("Comments: ");
        TextArea comments = new TextArea("",numRows,numCols,
                                TextArea.SCROLLBARS_VERTICAL_ONLY);
        comments.setBackground(Color.white);
        setComments(comments);
        // Add to the Frame.
        add(comments,"Center");

        // Add a Submit button.
        Button submit = new Button(submitString);
        submit.setActionCommand(submitString);
        submit.addActionListener(this);
        // Place the button in a Panel to limit its size.
        Panel p = new Panel();
        p.add(submit);
        add(p,"South");
    }

        // The Submit button has been pressed.
    public void actionPerformed(ActionEvent e){
        final String command = e.getActionCommand();
        if(command.equals(submitString)){
            System.out.println("Comments = "+comments.getText());
        }
        else{
            System.err.println("Unknown command: "+command);
        }
    }

    protected TextArea getComments(){
        return comments;
    }

    protected void setComments(TextArea commentArea){
        comments = commentArea;
    }

    // The label and action command of the submit button.
    private final String submitString = "Submit";
    // The text area.
    private TextArea comments;
}
