Ejemplo n.º 1
0
  /* (non-Javadoc)
   * Handles actions in the menu.
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(CLEAR_DATA)) {
      io.io.clearData();
    } else if (ColourScheme.isColourScheme(e.getActionCommand())) {
      if (e.getActionCommand().equals(SUNSET)) {
        setColourScheme(ColourScheme.SUNSET);
      } else if (e.getActionCommand().equals(DAWN)) {
        setColourScheme(ColourScheme.DAWN);
      } else if (e.getActionCommand().equals(DEFAULT)) {
        setDefaultColourScheme();
      }
    } else if (e.getActionCommand().equals(QUIT)) {
      /*
       * Fire a window closing event manually to ensure that this
       * is identical to the user(s) hitting the "X".
       */
      this.getToolkit()
          .getSystemEventQueue()
          .postEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    } else if (e.getActionCommand().equals(ABOUT)) {
      showDialouge(
          this,
          new Dimension(550, 300),
          ABOUT,
          ABOUT_MESSAGE,
          JOptionPane.OK_OPTION,
          LOGO,
          ModalityType.APPLICATION_MODAL);
    } else if (e.getActionCommand().equals(START_GAME)) {
      String betAmountString = JOptionPane.showInputDialog(this, BET_AMOUNT_START_MESSAGE);
      if (betAmountString != null && betAmountString.matches("\\d")) {
        int betAmount = Integer.parseInt(betAmountString);
        survivor.startGame(betAmount);

        JLabel round =
            new JLabel("Round: " + survivor.getCurrentRound() + " of " + survivor.getTotalRounds());
        round.setFont(Constants.BOLD_FONT);
        tabbedPane.setTabComponentAt(startGameTabIndex, round);
      }
    }
  }