/*
 * HelloWorldSwing.java
 * First Demo of a Swing Program
 * Example is based on an example from
 * http://java.sun.com/docs/books/tutorial/index.html
 */

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

public class HelloWorldSwing {
    public static void main(String[] args) {

	//constract the main frame
	JFrame frame = new JFrame("HelloWorldSwing");

	//constract a Jlabel component label
	final JLabel label = new JLabel("Hello World");

	//add to the frame the label component
	frame.getContentPane().add(label);

	/*
	 * Configure the default action for the "window close" command
	 * Two version are listed: the first one requires JSDK_1.3 and
	 * is commented out.  The second version will work with JSDK_1.2
	 * and above, and this is the version we use.
	 */

	// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //needs v1.3

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

	//set up and show the frame
	frame.pack();
	frame.setVisible(true);
    }
}
