import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * An example that uses some "advanced" features of buttons.
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class AdvancedButtonDriver
{
    
    /**
     * The entry point of the example
     *
     * @param args   The command line arguments
     */
    public static void main(String[] args)
    {
        Container   contentPane;
        JButton     noButton, yesButton;
	JFrame      window;
        JLabel      titleLabel;
        
	window = new JFrame("A Really Amazing Window!");
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // Get the content pane
        contentPane = window.getContentPane();
        contentPane.setLayout(null);

        // Construct the widgets.components
        titleLabel   = new JLabel("A Button Example");

        noButton     = new JButton("Non");
        noButton.setActionCommand("No");
        noButton.setMnemonic('N'); // There is also a setAccelerator() method.
   
       
        yesButton    = new JButton("Oui");
        yesButton.setActionCommand("Yes");
        yesButton.setMnemonic('O');
        
        // Layout the content pane
        contentPane.add(titleLabel);
        titleLabel.setBounds(60,20,290,30);

        contentPane.add(yesButton);
        yesButton.setBounds(190,210,60,30);
        
        contentPane.add(noButton);
        noButton.setBounds(260,210,90,30);
                
        // Make a ButtonHandler object an ActionListener on the buttons
        ButtonHandler handler = new ButtonHandler(titleLabel);
        
        yesButton.addActionListener(handler);
        noButton.addActionListener(handler);

	window.setSize(400,400);
	window.setVisible(true);
    }
}
