<commit_before>import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
// import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.Stack;

import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButtonMenuItem;

public class MineFrame
{
    //time the game was paused for
    private static double pauseTime = 0.0;
    private static double startPauseTime = 0;

    //Declare GUI objects
    private static JFrame frame;
    private static JPanel gamePanel;
    private static JLabel statusbar;

    //Generic int[] stacks
    public static Stack<int[]> undoStack = new Stack<int[]>();
    public static Stack<int[]> redoStack = new Stack<int[]>();

    //Declare static integers so that they can be accessed from static getters and setters.
    private static int noOfMines = 40;
    private static int noOfRows = 24;
    private static int noOfCols = 24;

    //Static boolean to be accessed across all classes
    public static boolean playingGame;

    //Static long which will contain the time a game has started in milliseconds
    private static long startTime;

    //Default width and height for the frame
    private static int height = 440;
    private static int width = 377;

    //Declare the menu bar and its items (GUI elements)
    private JMenuBar menuBar = new JMenuBar();
    private JMenu fileMenu, editMenu, viewMenu, helpMenu;
    private static JMenuItem pauseItem;
    private JMenuItem saveItem, loadItem, exitItem, newGameItem, resolveItem,
            undoItem, redoItem, highscore;
    private JRadioButtonMenuItem beginnerItem, intermediateItem, expertItem,
            customItem;
    private static Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); //center point of screen

    //Constructor of the MineFrame
    public MineFrame()
    {
        frame = new JFrame();//Create the frame for the GUI

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//Have the application exit when closed
        frame.setPreferredSize(new Dimension(width, height));//Set the preferred frame size
        frame.setLocationRelativeTo(null);//Centre the frame
        frame.setTitle("Minesweeper");//Title of the frame

        statusbar = new JLabel("");//Set the passed-in status bar

        gamePanel = new JPanel(new BorderLayout());//New panel that contains the board

        frame.setJMenuBar(buildMenuBar());//Build the menu bar and set it as the JMenuBar

        frame.add(gamePanel);//Add gamePanel to the frame
        startNewGame();

        frame.setBackground(new Color(0xB3B3B3));//Set Background colour
        frame.pack();//Resize the frame to occupy the smallest amount of space
        frame.setResizable(true);//Have the frame re-sizable useful for custom games
        frame.setVisible(true);//Show all components on the window
    }

    //Method to start/restart the game when a game has been lost, restarted or loaded
    public static void startNewGame()
    {
        gamePanel.removeAll();
        gamePanel.add(statusbar, BorderLayout.SOUTH);

        playingGame = true;//Set to true so the user may make actions
        startTime = System.currentTimeMillis(); //save the time the game started

        gamePanel.add(new Board(statusbar, getNoOfMines(), getNoOfRows(), getNoOfCols()));
        new SaveToDisk();//Save the generated board to disk
        //Arrays.fill(Board.getField(), 0);//Set all entries in the field to 0 to prove that LoadFromDisk does work
        new LoadFromDisk();//Load the board from disk
        frame.setPreferredSize(new Dimension(width, height));
        frame.setBounds(center.x - width / 2, center.y - height / 2, width,height); //calculate the center point of window and set it
        frame.validate();
        frame.repaint();
        frame.pack();
    }

    //Method to create the MenuBar, its properties and associate ActionListners
    public JMenuBar buildMenuBar()
    {
        //Create the fileMenu and it's items
        fileMenu = new JMenu("File");
        fileMenu.setMnemonic('F');
        saveItem = new JMenuItem("Save");
        saveItem.setMnemonic('S');
        saveItem.addActionListener(new SaveListener());
        loadItem = new JMenuItem("Load");
        loadItem.setMnemonic('L');
        loadItem.addActionListener(new LoadListener());
        highscore = new JMenuItem("Highscore");
        highscore.setMnemonic('H');
        highscore.addActionListener(new HighscoreListener());
        exitItem = new JMenuItem("Exit");
        exitItem.setMnemonic('X');
        exitItem.addActionListener(new ExitListener());

        //Add file items to the fileMenu
        fileMenu.add(saveItem);
        fileMenu.add(loadItem);
        fileMenu.add(highscore);
        fileMenu.add(exitItem);

        //Create the editMenu and it's items
        editMenu = new JMenu("Edit");
        editMenu.setMnemonic('d');
        undoItem = new JMenuItem("Undo");
        undoItem.setMnemonic('Z');
        undoItem.addActionListener(new UndoListener());
        redoItem = new JMenuItem("Redo");
        redoItem.setMnemonic('Y');
        redoItem.addActionListener(new RedoListener());

        //Add edit items to the editMenu
        editMenu.add(undoItem);
        editMenu.add(redoItem);

        //Create the viewMenu and it's items
        viewMenu = new JMenu("Game");
        viewMenu.setMnemonic('G');
        pauseItem = new JCheckBoxMenuItem("Pause");
        pauseItem.setMnemonic('P');
        pauseItem.addActionListener(new PauseListener());
        newGameItem = new JMenuItem("New Game");
        newGameItem.setMnemonic('N');
        newGameItem.addActionListener(new newGameListener());

        //Create difficulty radio buttons
        beginnerItem = new JRadioButtonMenuItem("Beginner");
        beginnerItem.setMnemonic('B');
        beginnerItem.addActionListener(new DifficultyListener());

        intermediateItem = new JRadioButtonMenuItem("Intermediate", true);
        intermediateItem.setMnemonic('I');
        intermediateItem.addActionListener(new DifficultyListener());

        expertItem = new JRadioButtonMenuItem("Expert");
        expertItem.setMnemonic('E');
        expertItem.addActionListener(new DifficultyListener());

        customItem = new JRadioButtonMenuItem("Custom...");
        customItem.setMnemonic('C');
        customItem.addActionListener(new CustomGameListener());

        //Create a button group and add the difficulty items to it
        ButtonGroup difficultyGroup = new ButtonGroup();
        difficultyGroup.add(beginnerItem);
        difficultyGroup.add(intermediateItem);
        difficultyGroup.add(expertItem);
        difficultyGroup.add(customItem);

        //Add difficulty and view items to viewMenu
        viewMenu.add(newGameItem);
        viewMenu.add(pauseItem);
        viewMenu.add(beginnerItem);
        viewMenu.add(intermediateItem);
        viewMenu.add(expertItem);
        viewMenu.add(customItem);

        //Create the helpMenu and it's item
        helpMenu = new JMenu("Help");
        helpMenu.setMnemonic('H');

        resolveItem = new JMenuItem("Solve Game");
        resolveItem.setMnemonic('c');
        resolveItem.addActionListener(new ResolveListener());

        //Add help item to helpMenu
        helpMenu.add(resolveItem);

        //Add File, View and Help Menus to the JMenuBar
        menuBar.add(fileMenu);
        menuBar.add(editMenu);
        menuBar.add(viewMenu);
        menuBar.add(helpMenu);

        // return the menuBar
        return menuBar;
    }

    //Accessors and mutators
<commit_msg>add separators in menu items<commit_after>import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
// import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.Stack;

import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButtonMenuItem;

public class MineFrame
{
    //time the game was paused for
    private static double pauseTime = 0.0;
    private static double startPauseTime = 0;

    //Declare GUI objects
    private static JFrame frame;
    private static JPanel gamePanel;
    private static JLabel statusbar;

    //Generic int[] stacks
    public static Stack<int[]> undoStack = new Stack<int[]>();
    public static Stack<int[]> redoStack = new Stack<int[]>();

    //Declare static integers so that they can be accessed from static getters and setters.
    private static int noOfMines = 40;
    private static int noOfRows = 24;
    private static int noOfCols = 24;

    //Static boolean to be accessed across all classes
    public static boolean playingGame;

    //Static long which will contain the time a game has started in milliseconds
    private static long startTime;

    //Default width and height for the frame
    private static int height = 440;
    private static int width = 377;

    //Declare the menu bar and its items (GUI elements)
    private JMenuBar menuBar = new JMenuBar();
    private JMenu fileMenu, editMenu, viewMenu, helpMenu;
    private static JMenuItem pauseItem;
    private JMenuItem saveItem, loadItem, exitItem, newGameItem, resolveItem,
            undoItem, redoItem, highscore;
    private JRadioButtonMenuItem beginnerItem, intermediateItem, expertItem,
            customItem;
    private static Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); //center point of screen

    //Constructor of the MineFrame
    public MineFrame()
    {
        frame = new JFrame();//Create the frame for the GUI

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//Have the application exit when closed
        frame.setPreferredSize(new Dimension(width, height));//Set the preferred frame size
        frame.setLocationRelativeTo(null);//Centre the frame
        frame.setTitle("Minesweeper");//Title of the frame

        statusbar = new JLabel("");//Set the passed-in status bar

        gamePanel = new JPanel(new BorderLayout());//New panel that contains the board

        frame.setJMenuBar(buildMenuBar());//Build the menu bar and set it as the JMenuBar

        frame.add(gamePanel);//Add gamePanel to the frame
        startNewGame();

        frame.setBackground(new Color(0xB3B3B3));//Set Background colour
        frame.pack();//Resize the frame to occupy the smallest amount of space
        frame.setResizable(true);//Have the frame re-sizable useful for custom games
        frame.setVisible(true);//Show all components on the window
    }

    //Method to start/restart the game when a game has been lost, restarted or loaded
    public static void startNewGame()
    {
        gamePanel.removeAll();
        gamePanel.add(statusbar, BorderLayout.SOUTH);

        playingGame = true;//Set to true so the user may make actions
        startTime = System.currentTimeMillis(); //save the time the game started

        gamePanel.add(new Board(statusbar, getNoOfMines(), getNoOfRows(), getNoOfCols()));
        new SaveToDisk();//Save the generated board to disk
        //Arrays.fill(Board.getField(), 0);//Set all entries in the field to 0 to prove that LoadFromDisk does work
        new LoadFromDisk();//Load the board from disk
        frame.setPreferredSize(new Dimension(width, height));
        frame.setBounds(center.x - width / 2, center.y - height / 2, width,height); //calculate the center point of window and set it
        frame.validate();
        frame.repaint();
        frame.pack();
    }

    //Method to create the MenuBar, its properties and associate ActionListners
    public JMenuBar buildMenuBar()
    {
        //Create the fileMenu and it's items
        fileMenu = new JMenu("File");
        fileMenu.setMnemonic('F');
        saveItem = new JMenuItem("Save");
        saveItem.setMnemonic('S');
        saveItem.addActionListener(new SaveListener());
        loadItem = new JMenuItem("Load");
        loadItem.setMnemonic('L');
        loadItem.addActionListener(new LoadListener());
        highscore = new JMenuItem("Highscore");
        highscore.setMnemonic('H');
        highscore.addActionListener(new HighscoreListener());
        exitItem = new JMenuItem("Exit");
        exitItem.setMnemonic('X');
        exitItem.addActionListener(new ExitListener());

        //Add file items to the fileMenu
        fileMenu.add(saveItem);
        fileMenu.add(loadItem);
        fileMenu.addSeparator();
        fileMenu.add(highscore);
        fileMenu.add(exitItem);

        //Create the editMenu and it's items
        editMenu = new JMenu("Edit");
        editMenu.setMnemonic('d');
        undoItem = new JMenuItem("Undo");
        undoItem.setMnemonic('Z');
        undoItem.addActionListener(new UndoListener());
        redoItem = new JMenuItem("Redo");
        redoItem.setMnemonic('Y');
        redoItem.addActionListener(new RedoListener());

        //Add edit items to the editMenu
        editMenu.add(undoItem);
        editMenu.add(redoItem);

        //Create the viewMenu and it's items
        viewMenu = new JMenu("Game");
        viewMenu.setMnemonic('G');
        pauseItem = new JCheckBoxMenuItem("Pause");
        pauseItem.setMnemonic('P');
        pauseItem.addActionListener(new PauseListener());
        newGameItem = new JMenuItem("New Game");
        newGameItem.setMnemonic('N');
        newGameItem.addActionListener(new newGameListener());

        //Create difficulty radio buttons
        beginnerItem = new JRadioButtonMenuItem("Beginner");
        beginnerItem.setMnemonic('B');
        beginnerItem.addActionListener(new DifficultyListener());

        intermediateItem = new JRadioButtonMenuItem("Intermediate", true);
        intermediateItem.setMnemonic('I');
        intermediateItem.addActionListener(new DifficultyListener());

        expertItem = new JRadioButtonMenuItem("Expert");
        expertItem.setMnemonic('E');
        expertItem.addActionListener(new DifficultyListener());

        customItem = new JRadioButtonMenuItem("Custom...");
        customItem.setMnemonic('C');
        customItem.addActionListener(new CustomGameListener());

        //Create a button group and add the difficulty items to it
        ButtonGroup difficultyGroup = new ButtonGroup();
        difficultyGroup.add(beginnerItem);
        difficultyGroup.add(intermediateItem);
        difficultyGroup.add(expertItem);
        difficultyGroup.add(customItem);

        //Add difficulty and view items to viewMenu
        viewMenu.add(newGameItem);
        viewMenu.add(pauseItem);
        viewMenu.addSeparator();
        viewMenu.add(beginnerItem);
        viewMenu.add(intermediateItem);
        viewMenu.add(expertItem);
        viewMenu.add(customItem);

        //Create the helpMenu and it's item
        helpMenu = new JMenu("Help");
        helpMenu.setMnemonic('H');

        resolveItem = new JMenuItem("Solve Game");
        resolveItem.setMnemonic('c');
        resolveItem.addActionListener(new ResolveListener());

        //Add help item to helpMenu
        helpMenu.add(resolveItem);

        //Add File, View and Help Menus to the JMenuBar
        menuBar.add(fileMenu);
        menuBar.add(editMenu);
        menuBar.add(viewMenu);
        menuBar.add(helpMenu);

        // return the menuBar
        return menuBar;
    }

    //Accessors and mutators

{'fraction_non_alphanumeric': 0.09791500092256597, 'fraction_numerical': 0.0028292022879635895, 'mean_word_length': 3.041759880686055, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4758955', 'n_tokens_mistral': 4524, 'n_tokens_neox': 4377, 'n_words': 1254}