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

import java.awt.event.*;
class MyPanel extends Panel implements ActionListener
{
	Button b1 = new Button("On");
	Button b2 = new Button("Off");
	MyPanel()
	{
		setLayout(new GridLayout());
		add(new Panel());
		add(b1);
		add(b2);
		add(new Panel());
		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);
		}
	}
}

public class E1
{
	public static void main(String args[])
	{
		Frame f = new Frame();
		f.add(BorderLayout.NORTH, new Panel());
        	f.add(BorderLayout.CENTER, new MyPanel());
		f.add(BorderLayout.SOUTH, new Panel());
        	f.show();
	}
}
