  // A Simple Swing Application

  import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;

  public class SimpleSwingApplication extends JFrame implements ActionListener
  {
	
	private JButton button1, button2;
	private JTextField status;
	
	public SimpleSwingApplication()
	{
	  // call the parent class constructor - sets the frame title
	  super("Simple Swing Example");

	  this.status = new JTextField(20);
	  this.button1 = new JButton("Button 1");
	  this.button2 = new JButton("Button 2");

	  this.button1.addActionListener(this);
	  this.button2.addActionListener(this);

	  // default layout is border layout for frame/jframe
	  this.getContentPane().add("North",this.status);
	  this.getContentPane().add("Center",this.button1);
	  this.getContentPane().add("South",this.button2);

	  this.pack();  //set the size of the frame according 
			//to the component's preferred sizes
	  this.show();	//make the frame visible
	}
	
	public void actionPerformed(ActionEvent e)
	{
	  if (e.getActionCommand().equals("Button 1"))
	  {
	    this.status.setText("Button 1 Pressed");
	  }
	  else if (e.getActionCommand().equals("Button 2"))
	  {
	    status.setText("Button 2 Pressed");
	  }
	}

	public static void main(String args[])
	{
	   new SimpleSwingApplication();
	}
  }