import java.awt.*;

public class MyApp extends Frame
{
	// "final" variables are constants
	static final int H_SIZE = 300;
	static final int V_SIZE = 200;
	
	StatusBar sb;
	ToolBar tb;

	public MyApp()
	{
		// Calls the parent constructor 
		// Frame(string title)
		// Equivalent to setTitle("My First Application")
		super("My First Application");
		setFont(new Font("TimesRoman", Font.PLAIN, 12));
		setBackground(Color.white);
		setForeground(Color.black);
		setLayout(new BorderLayout());

		add("North", tb = new ToolBar());
		add("South", sb = new StatusBar());
		pack();
		resize(H_SIZE, V_SIZE);
		show();
	}

	public boolean handleEvent(Event evt)
	{
		switch(evt.id)
		{
			case Event.WINDOW_DESTROY:
			{
				System.exit(0);
				return true;
			}
			case Event.ACTION_EVENT:
			{
				sb.showStatus(evt.arg.toString());
				return true;
			}
			default:
				return false;
		}
	}

	public static void main(String args[])
	{
		new MyApp();
	}
}

class ToolBar extends Panel
{
	public ToolBar()
	{
		setLayout(new FlowLayout());
		add(new Button("Open"));
		add(new Button("Save"));
		add(new Button("Close"));
		Choice c = new Choice();
		c.addItem("Times Roman");
		c.addItem("Helvetica");
		c.addItem("System"); 
		add(c);
		add(new Button("Help"));
	}
}

class StatusBar extends Panel
{
	Label info;
	Label other;

	public StatusBar()
	{
		setLayout(new FlowLayout());
		add(info = new Label("StatusBar created"));
		add(other = new Label("Other info"));
	}

	public void showStatus(String status)
	{
		info.setText(status);
	}
}

