// Allison Obourn
// CS& 141, Winter 2021
// Lecture 15

// Creates a GUI with two buttons, a blue on on the left and a red
// one on the right. When the buttons are pressed a dialog box
// pops up. 

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class GUIExample1 {
    public static void main(String[] args) {
        JFrame window = new JFrame();
        window.setSize(new Dimension(300, 100));
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setLayout(new FlowLayout());
        
        JButton button1 = new JButton("This is a button");
        button1.setBackground(Color.BLUE); 
        MyActionListener listener = new MyActionListener();
        button1.addActionListener(listener);
        
        JButton button2 = new JButton("another button");
        button2.setBackground(Color.RED); 
        button2.addActionListener(listener);

        // add buttons to the interface so we can see them
        window.add(button1);
        window.add(button2);
        
        window.setVisible(true);
    }
}

