// 140509 TA public void goToNextGamePanel() { this.getCardLayout().show(this.getcontentPane(), "Main"); this.getCurrentPanel().hide(); currentPanel = gamePanel.getNextPanel(); nbrButtons = gamePanel.nbrGamesOnPanel(gamePanel.getCurrentPanelId()); this.currentPanel.show(); }
// 140509 TA public void goToPreviousGamePanel() { this.getCardLayout().show(this.getcontentPane(), "Main"); this.getCurrentPanel().hide(); currentPanel = gamePanel.getPreviousPanel(); nbrButtons = gamePanel.nbrGamesOnPanel(gamePanel.getCurrentPanelId()); System.out.println(nbrButtons + " " + gamePanel.getCurrentPanelId()); this.currentPanel.show(); }
// 140509 TA public String gameButtonPressed(int selectedButton) { String[] list = gamePanel.getListOfGames(); String file = ""; // Calculate which button was actually pressed, based on which panel is // shown and which button (0-x) is selected. int gameNumber = gamePanel.getCurrentPanelId() * gamePanel.getNbrGamesPerPage() + selectedButton; file = list[gameNumber]; return file; }
public void addGamePanels() { gamePanel = new GameSelectionPanels(resWidth, resHeight); for (int i = 0; i < gamePanel.getNumberOfPanels(); i++) { // Adds the // game // panels to // the // content // pane. contentPane.add(gamePanel.getPanel(i), "p1"); } this.controller.updateButtons(gamePanel.buttons()); }
/** Constructor for the GUI */ public GUI_Pi(Controller controller) { this.controller = controller; KeyDetector key = new KeyDetector(this, controller); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); resWidth = screenSize.width; resHeight = screenSize.height; initGui(); mainMenu.setName("Main"); // gamesMenu panels are initiated and given their name in a separate // class optionsMenu.setName("Options"); aboutMenu.setName("About"); this.controller.updateButtons(Main_Menu_Buttons); this.controller.updateButtons(gamePanel.buttons()); this.contentPane.revalidate(); this.contentPane.repaint(); }
// 140509 TA public void setCurrentPanel(String panelName) { if (panelName.equals("Main")) currentPanel = mainMenu; else if (panelName.equals("Games")) currentPanel = gamePanel.getPanel(0); else if (panelName.equals("Options")) currentPanel = optionsMenu; else if (panelName.equals("About")) currentPanel = aboutMenu; }
/** * Returns the 1st game panel * * @return game menu panel */ public JPanel getGamePanel() { return gamePanel.getPanel(0); }