import javax.swing.*;
import java.awt.event.*;
public class StatusApplet extends JApplet
implements ActionListener
{
	final String CLEAR_STATUS = "clear_status";	
	final String CLEAR_FIELD = "clear_field";
	
	JButton button = new JButton("Set Status");
	JButton clearButton = new JButton("Clear");
	JTextField tfield  = new JTextField(20);
	JPanel	panel	= new JPanel();
	
	public void init()
	{
		button.addActionListener(this);
		clearButton.addActionListener(this);
		clearButton.setActionCommand(CLEAR_STATUS);
		tfield.addActionListener(this);
		panel.add(tfield);
		panel.add(button);
		panel.add(clearButton);
		this.getContentPane().add(panel);
	}
	
	// satisifies implementation of ActionListener
	public void actionPerformed(ActionEvent evt)
	{
		String command = evt.getActionCommand();
		if(command.equals(CLEAR_STATUS))
		{
	   		this.showStatus("");
			clearButton.setActionCommand(CLEAR_FIELD);
			return;
		}
		else if(command.equals(CLEAR_FIELD))
		{
			tfield.setText("");
			return;
		}
		this.showStatus(tfield.getText().trim());
		clearButton.setActionCommand(CLEAR_STATUS);
	}
}
