import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
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;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/*
 * JButtonsExample.java
 *
 * Created on March 5, 2005, 2:23 PM
 */

/**
 *
 * @author Bill Kraynek
 */
public class JButtonsExample {
    
    /** Creates a new instance of JButtonsExample */
    public JButtonsExample() {
        JFrame theFrame = new JFrame("JButtons Example");
        theFrame.setSize(400,400);
        theFrame.setLayout(new FlowLayout(FlowLayout.CENTER,300,20));
        JPanel button1Panel = new JPanel();
        button1Panel.setBackground(Color.GREEN);
        JLabel label1 = new JLabel("Label 1");
        JButton button1 = new JButton("Button1");
        button1Panel.add(label1);
        button1Panel.add(button1);
        button1.addActionListener(new Button1Action());
        JScrollPane pane1 = new JScrollPane(button1Panel);
        theFrame.add(pane1);
        JPanel button2Panel = new JPanel();
        button2Panel.setBackground(Color.RED);
        JButton button2 = new JButton("Button2");
        button2.setBackground(Color.YELLOW);
        button2.addActionListener(new Button1Action());
        button2Panel.add(button2);
        theFrame.add(button2Panel);
        theFrame.setVisible(true);
    }
    
    class Button1Action implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null,e.getActionCommand());            
        }
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new JButtonsExample();
    }
    
}

