/** SampleGUI.java
 *
 * This is an application that displays 
 * common GUI components.
 */

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

public class SampleGUI
{
    // Member declarations
    //
    JFrame	    frame;
    JPanel	    contentPane;
    JLabel	    label;
    JButton	    button;
    JRadioButton    radioBtnOne, radioBtnTwo;
    JCheckBox	    checkBox;
    JTextField	    textField;
    JLabel	    tooltipLabel;
    
    // Optional button group for the radiobuttons
    ButtonGroup    btnGroup;
    
    /** 
      * Constructor for SampleGUI
      */ 
    public SampleGUI()
    {
	frame	    = new JFrame("Sample GUI Components");
	contentPane = (JPanel)frame.getContentPane();
	
	label	    = new JLabel("A label");
	button	    = new JButton("A button");
	radioBtnOne = new JRadioButton("A radio button");
	radioBtnTwo = new JRadioButton("Another radio button");
	checkBox    = new JCheckBox("A checkbox", true);
	textField   = new JTextField("A textfield", 20);
	tooltipLabel= new JLabel("A label with a tooltip");
	
	contentPane.setLayout(new FlowLayout());
	tooltipLabel.setToolTipText("A Tooltip");
	
	// Add components to the frame's content pane
	contentPane.add(label);
	contentPane.add(button);
	contentPane.add(radioBtnOne);
	contentPane.add(radioBtnTwo);
	contentPane.add(checkBox);
	contentPane.add(textField);
	contentPane.add(tooltipLabel);
	
	// Add radio buttons to button group
	btnGroup = new ButtonGroup();
	btnGroup.add(radioBtnOne);
	btnGroup.add(radioBtnTwo);
	
	// Make our window visible
	frame.setSize(300,200);
	frame.setVisible(true);
	
	// Exit application when window is closed
	frame.addWindowListener(new WindowAdapter()
	{
	    public void windowClosing(WindowEvent evt)
	    {
		System.exit(0);
	    }
	});
    }
    
    public static void main(String argv[])
    {
	SampleGUI sGUI = new SampleGUI();
    }
}
	
