import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class FirstGUI
{
  public Component createComponents()
    {
      // Create and return a panel containing our low-level components
      JButton button = new JButton("Isn't this a nice button?");
      JPanel pane = new JPanel();
      pane.add(button);

      return pane;
    }

  public static void main(String[] args)
    {
      JFrame frame = new JFrame("Mary's First GUI");
      FirstGUI gui = new FirstGUI(); // create an instance on which to call
      // createComponents method
      Component contentsPanel = gui.createComponents();
      frame.getContentPane().add(contentsPanel);

      // Make the frame closeable
      frame.addWindowListener(new WindowAdapter()
	{
	  public void windowClosing(WindowEvent e)
	    {
	      System.exit(0);
	    }
	});

      // Make frame bigger and visible
      frame.setLocation(200, 300);
      frame.setSize(300, 100);
      frame.setVisible(true);
    }
}
  
