src/gui/GUI.java
private static void AddMenus() {

        // Add the menu bar.
        menuBar = new JMenuBar();

        fileMenu = new JMenu("File");
        newGameItem = new JMenuItem("New Game");
        undoItem = new JMenuItem("Undo    Ctrl+Z");
        redoItem = new JMenuItem("Redo    Ctrl+Y");
        saveGameItem = new JMenuItem("Save Game");
        restoreSavedGameItem = new JMenuItem("Restore Saved Game");
        loadNovelPositionItem = new JMenuItem("Load Novel Position");
        exportToGifItem = new JMenuItem("Export to .gif");
        settingsItem = new JMenuItem("Settings");
        exitItem = new JMenuItem("Exit");

        helpMenu = new JMenu("Help");
        howToPlayItem = new JMenuItem("How to Play");
        aboutItem = new JMenuItem("About");

        undoItem.setEnabled(false);
        redoItem.setEnabled(false);

        newGameItem.addActionListener(e -> createNewGame());

        undoItem.addActionListener(e -> undo());

        redoItem.addActionListener(e -> redo());

        saveGameItem.addActionListener(e -> {
            saveGame();
            System.out.println("Game saved!");
        });

        restoreSavedGameItem.addActionListener(e -> {
            restoreSavedGame();
            System.out.println("Last saved game restored!");
        });

        loadNovelPositionItem.addActionListener(e -> {
            LoadNovelPositionWindow lnpw = new LoadNovelPositionWindow();
            lnpw.setVisible(true);
            System.out.println("Novel game position loaded!");
        });

        exportToGifItem.addActionListener(e -> exportToGif());

        settingsItem.addActionListener(e -> {
            SettingsWindow settings = new SettingsWindow();
            settings.setVisible(true);
        });

        exitItem.addActionListener(e -> System.exit(0));

        howToPlayItem.addActionListener(e -> JOptionPane.showMessageDialog(null,
                "Click on the buttons or press 1-" + NUM_OF_COLUMNS + " on your keyboard to insert a new checker."
                        + "\nTo win you must place " + CHECKERS_IN_A_ROW + " checkers in an row, horizontally, vertically or diagonally.",
                "How to Play", JOptionPane.INFORMATION_MESSAGE));

        aboutItem.addActionListener(e -> {
            JLabel label = new JLabel("<html><center>© Created by: Christos Kormaris<br>"
                    + "Version " + Constants.VERSION + "</center></html>");
            JOptionPane.showMessageDialog(frameMainWindow, label, "About", JOptionPane.INFORMATION_MESSAGE);
        });

        fileMenu.add(newGameItem);
        fileMenu.add(undoItem);
        fileMenu.add(redoItem);
        fileMenu.add(saveGameItem);
        fileMenu.add(restoreSavedGameItem);
        fileMenu.add(loadNovelPositionItem);
        fileMenu.add(exportToGifItem);
        fileMenu.add(settingsItem);
        fileMenu.add(exitItem);

        helpMenu.add(howToPlayItem);
        helpMenu.add(aboutItem);

        menuBar.add(fileMenu);
        menuBar.add(helpMenu);

        frameMainWindow.setJMenuBar(menuBar);
        // Make the board visible after adding the menus.
        frameMainWindow.setVisible(true);

    }
// Add the menu bars and items to the window.
Add the menu bars and items to the window.
Add the menu bars and items to the window .
private static void AddMenus() {
        menuBar = new JMenuBar();
        fileMenu = new JMenu("File");
        newGameItem = new JMenuItem("New Game");
        undoItem = new JMenuItem("Undo    Ctrl+Z");
        redoItem = new JMenuItem("Redo    Ctrl+Y");
        saveGameItem = new JMenuItem("Save Game");
        restoreSavedGameItem = new JMenuItem("Restore Saved Game");
        loadNovelPositionItem = new JMenuItem("Load Novel Position");
        exportToGifItem = new JMenuItem("Export to .gif");
        settingsItem = new JMenuItem("Settings");
        exitItem = new JMenuItem("Exit");
        helpMenu = new JMenu("Help");
        howToPlayItem = new JMenuItem("How to Play");
        aboutItem = new JMenuItem("About");
        undoItem.setEnabled(false);
        redoItem.setEnabled(false);
        newGameItem.addActionListener(e -> createNewGame());
        undoItem.addActionListener(e -> undo());
        redoItem.addActionListener(e -> redo());
        saveGameItem.addActionListener(e -> {
            saveGame();
            System.out.println("Game saved!");
        });
        restoreSavedGameItem.addActionListener(e -> {
            restoreSavedGame();
            System.out.println("Last saved game restored!");
        });
        loadNovelPositionItem.addActionListener(e -> {
            LoadNovelPositionWindow lnpw = new LoadNovelPositionWindow();
            lnpw.setVisible(true);
            System.out.println("Novel game position loaded!");
        });
        exportToGifItem.addActionListener(e -> exportToGif());
        settingsItem.addActionListener(e -> {
            SettingsWindow settings = new SettingsWindow();
            settings.setVisible(true);
        });
        exitItem.addActionListener(e -> System.exit(0));
        howToPlayItem.addActionListener(e -> JOptionPane.showMessageDialog(null,
                "Click on the buttons or press 1-" + NUM_OF_COLUMNS + " on your keyboard to insert a new checker."
                        + "\nTo win you must place " + CHECKERS_IN_A_ROW + " checkers in an row, horizontally, vertically or diagonally.",
                "How to Play", JOptionPane.INFORMATION_MESSAGE));
        aboutItem.addActionListener(e -> {
            JLabel label = new JLabel("<html><center>© Created by: Christos Kormaris<br>"
                    + "Version " + Constants.VERSION + "</center></html>");
            JOptionPane.showMessageDialog(frameMainWindow, label, "About", JOptionPane.INFORMATION_MESSAGE);
        });
        fileMenu.add(newGameItem);
        fileMenu.add(undoItem);
        fileMenu.add(redoItem);
        fileMenu.add(saveGameItem);
        fileMenu.add(restoreSavedGameItem);
        fileMenu.add(loadNovelPositionItem);
        fileMenu.add(exportToGifItem);
        fileMenu.add(settingsItem);
        fileMenu.add(exitItem);
        helpMenu.add(howToPlayItem);
        helpMenu.add(aboutItem);
        menuBar.add(fileMenu);
        menuBar.add(helpMenu);
        frameMainWindow.setJMenuBar(menuBar);
        frameMainWindow.setVisible(true);
    }
private static void AddMenus ( ) { menuBar = new JMenuBar ( ) ; fileMenu = new JMenu ( "File" ) ; newGameItem = new JMenuItem ( "New Game" ) ; undoItem = new JMenuItem ( "Undo    Ctrl+Z" ) ; redoItem = new JMenuItem ( "Redo    Ctrl+Y" ) ; saveGameItem = new JMenuItem ( "Save Game" ) ; restoreSavedGameItem = new JMenuItem ( "Restore Saved Game" ) ; loadNovelPositionItem = new JMenuItem ( "Load Novel Position" ) ; exportToGifItem = new JMenuItem ( "Export to .gif" ) ; settingsItem = new JMenuItem ( "Settings" ) ; exitItem = new JMenuItem ( "Exit" ) ; helpMenu = new JMenu ( "Help" ) ; howToPlayItem = new JMenuItem ( "How to Play" ) ; aboutItem = new JMenuItem ( "About" ) ; undoItem . setEnabled ( false ) ; redoItem . setEnabled ( false ) ; newGameItem . addActionListener ( e -> createNewGame ( ) ) ; undoItem . addActionListener ( e -> undo ( ) ) ; redoItem . addActionListener ( e -> redo ( ) ) ; saveGameItem . addActionListener ( e -> { saveGame ( ) ; System . out . println ( "Game saved!" ) ; } ) ; restoreSavedGameItem . addActionListener ( e -> { restoreSavedGame ( ) ; System . out . println ( "Last saved game restored!" ) ; } ) ; loadNovelPositionItem . addActionListener ( e -> { LoadNovelPositionWindow lnpw = new LoadNovelPositionWindow ( ) ; lnpw . setVisible ( true ) ; System . out . println ( "Novel game position loaded!" ) ; } ) ; exportToGifItem . addActionListener ( e -> exportToGif ( ) ) ; settingsItem . addActionListener ( e -> { SettingsWindow settings = new SettingsWindow ( ) ; settings . setVisible ( true ) ; } ) ; exitItem . addActionListener ( e -> System . exit ( 0 ) ) ; howToPlayItem . addActionListener ( e -> JOptionPane . showMessageDialog ( null , "Click on the buttons or press 1-" + NUM_OF_COLUMNS + " on your keyboard to insert a new checker." + "\nTo win you must place " + CHECKERS_IN_A_ROW + " checkers in an row, horizontally, vertically or diagonally." , "How to Play" , JOptionPane . INFORMATION_MESSAGE ) ) ; aboutItem . addActionListener ( e -> { JLabel label = new JLabel ( "<html><center>© Created by: Christos Kormaris<br>" + "Version " + Constants . VERSION + "</center></html>" ) ; JOptionPane . showMessageDialog ( frameMainWindow , label , "About" , JOptionPane . INFORMATION_MESSAGE ) ; } ) ; fileMenu . add ( newGameItem ) ; fileMenu . add ( undoItem ) ; fileMenu . add ( redoItem ) ; fileMenu . add ( saveGameItem ) ; fileMenu . add ( restoreSavedGameItem ) ; fileMenu . add ( loadNovelPositionItem ) ; fileMenu . add ( exportToGifItem ) ; fileMenu . add ( settingsItem ) ; fileMenu . add ( exitItem ) ; helpMenu . add ( howToPlayItem ) ; helpMenu . add ( aboutItem ) ; menuBar . add ( fileMenu ) ; menuBar . add ( helpMenu ) ; frameMainWindow . setJMenuBar ( menuBar ) ; frameMainWindow . setVisible ( true ) ; }
Add the menu bars and items to the window.
Add the menu bars and items to the window .
// Add the menu bar. // Make the board visible after adding the menus.