/*
 * MyFirst solo Project Spring 2014
 * Matching Card Game
 */

package view;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.BorderFactory;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.border.Border;

/**
 * This class creates a JMenuBar that is placed on the north of the GUI.
 * 
 * @author Brian Dennis
 * @version 3-29-2014
 */
@SuppressWarnings("serial")
public class MenuBar extends JMenuBar implements ActionListener {
    
    /** the object that reference the JOPtionpane to change deck values. */
    private final ChangeDeck myChangeDeck;
    
    /**
     * The constructor that initializes the variable of the menu bar.
     * 
     * @param theFrame the frame for the card game
     */
    public MenuBar(final MatchingGameGUI theFrame) {
        
        super();
        myChangeDeck = new ChangeDeck(theFrame);
        start();
    }
    
    /**
     * The start method to build stuff.
     */
    private void start() {
        
        final Border border = BorderFactory.createCompoundBorder(
                                     BorderFactory.createLineBorder(Color.BLACK, 2),
                                     BorderFactory.createMatteBorder(4, 4, 4, 4, Color.BLUE));
        setBorder(border);
        final JMenu gameOptions = new JMenu("Game Options");
        gameOptions.setMnemonic(KeyEvent.VK_G);
        final JMenuItem changeCards = new JMenuItem("Change number of cards...");
        changeCards.setMnemonic(KeyEvent.VK_C);
        changeCards.addActionListener(this);
        
        gameOptions.add(changeCards);
        add(gameOptions);
    }

    @Override
    public void actionPerformed(final ActionEvent arg0) {
        
        myChangeDeck.triggereOptionPane();
    }
}