
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Bill Kraynek
 */
public class GUISample {
    
    public GUISample() {
        JFrame theFrame = new JFrame("GUI Sample");
        Toolkit tk = Toolkit.getDefaultToolkit();
        int width = (int) (tk.getScreenSize().getWidth()) / 2;
        int height = (int) (tk.getScreenSize().getHeight()) / 2;
        theFrame.setSize(width, height);
        theFrame.setLocation(width / 2, height / 2);
        theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        theFrame.setLayout(new FlowLayout(FlowLayout.CENTER, 30, 30));
        JLabel label1 = new JLabel("Label 1");
        JButton button1 = new JButton("Button 1");
        button1.addActionListener(new ButtonAction());
        theFrame.add(label1);
        theFrame.add(button1);
        theFrame.setVisible(true);
    }

    class ButtonAction implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            String buttonLabel = e.getActionCommand();
            JOptionPane.showMessageDialog(null, buttonLabel + " was clicked");
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new GUISample();
    }

}

