Пример #1
0
  public void update(Observable o, Object arg) {

    String gameStatus = model.getStatus();

    if (gameStatus.equals("finished")) {
      statusbar.setText("Game over. You won.");
    } else if (gameStatus.equals("paused")) {
      statusbar.setText("Paused");
    } else if (gameStatus.equals("game over")) {
      statusbar.setText("Game over. You lost.");
    } else {
      statusbar.setText(
          "Your score: "
              + new Integer(model.getScore()).toString()
              + ", level "
              + new Integer(model.getLevel()).toString());
      board.repaint();
    }
  }
Пример #2
0
  public void drawMap() {
    contentPane.removeAll();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    JPanel ligneIndication = new JPanel();
    ligneIndication.setLayout(new GridLayout(1, 3));
    JPanel caseLevel = new JPanel();
    JLabel texteLevel = new JLabel("Level : ");
    caseLevel.add(texteLevel);
    level = new JLabel(String.valueOf(model.getLevel()));
    caseLevel.add(level);
    ligneIndication.add(caseLevel);

    JPanel caseTries = new JPanel();
    JLabel texteTries = new JLabel("Tries : ");
    caseTries.add(texteTries);
    tries = new JLabel(String.valueOf(model.getTries()));
    caseTries.add(tries);
    ligneIndication.add(caseTries);

    JPanel caseScore = new JPanel();
    JLabel texteScore = new JLabel("Score : ");
    caseScore.add(texteScore);
    score = new JLabel(String.valueOf(model.getScore()));
    caseScore.add(score);
    ligneIndication.add(caseScore);

    contentPane.add(ligneIndication);

    JPanel sousContentPane = new JPanel();
    sousContentPane.setLayout(new GridLayout(8, 8));
    for (int i = 0; i < tableauBijouButton.length; i++) {
      for (int j = 0; j < tableauBijouButton.length; j++) {
        sousContentPane.add(tableauBijouButton[i][j]);
        tableauBijouButton[i][j].setPreferredSize(new Dimension(60, 60));
      }
    }
    contentPane.add(sousContentPane);

    contentPane.add(progressBar.getProgressBar());

    // coloreCoupPossible();
    setContentPane(contentPane);
  }