/*
	Event Handling Example 5
*/
import java.awt.*;

import java.awt.event.*;
class MyFrame extends Frame implements ActionListener
{
	Button b1 = new Button("On");
	Button b2 = new Button("Off");
	TextField t1 = new TextField("Some Text", 20);
	Panel p1 = new Panel(new FlowLayout());

	MyFrame ()
	{
		setLayout(new BorderLayout());
		add(BorderLayout.EAST, b1);
		add(BorderLayout.WEST, b2);
		add(BorderLayout.CENTER, p1);
		p1.add(t1);
		b2.setVisible(false);
		b1.addActionListener(this);
		b2.addActionListener(this);
	}
	
	public void actionPerformed (ActionEvent e)
	{
		if (e.getActionCommand() == "On")
		{
			b1.setVisible(false) ;
			b2.setVisible(true);
		}
		else if (e.getActionCommand() == "Off")
		{
			b2.setVisible(false);
			b1.setVisible(true);
		}
		t1.setText(" " + e.getActionCommand() + " " + "Button Pressed");
		resize(300, 150);
	}
}

public class E5
{
	public static void main(String args[])
	{
		MyFrame f = new MyFrame();
        	f.resize(300, 100);
       		f.show();
	}
}
