From 84d2395eaac1bf6234d6e3296eb8dd4373dedeb1 Mon Sep 17 00:00:00 2001 From: Thoumi Ngonga Brice Date: Wed, 8 Feb 2023 15:56:57 +0100 Subject: [PATCH] Update Methode void BuildGui and add class NewGameListener --- src/main/java/BattleShip/BShip.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/BattleShip/BShip.java b/src/main/java/BattleShip/BShip.java index cda0dd8..6b9054c 100644 --- a/src/main/java/BattleShip/BShip.java +++ b/src/main/java/BattleShip/BShip.java @@ -1,6 +1,8 @@ package BattleShip; import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; public class BShip { @@ -35,6 +37,19 @@ public class BShip { boardSize[1] = new JMenuItem("10x10"); boardSize[2] = new JMenuItem("12x12"); + JMenuBar bar = new JMenuBar(); + JMenu menu = new JMenu("file"); + JMenuItem newGame = new JMenuItem("New Game"); + newGame.addActionListener(new NewGameListener()); + JMenu sizes = new JMenu("Board Size"); + for(int i = 0; i < boardSize.length; i++) { + boardSize[i].addActionListener(new NewGameListener()); + sizes.add(boardSize[i]); + } + } + + public class NewGameListener implements ActionListener { + public void actionPerformed(ActionEvent a) {} } }