예제 #1
0
  public void mousePressed(MouseEvent e) {
    if (e.getButton() != MouseEvent.BUTTON3) return;

    JButton bouton = (JButton) e.getSource();
    i = champMine.getLingeBouton(bouton.getName());
    j = champMine.getColonneBouton(bouton.getName());

    if (champMine.estCaseNormale(i, j)) champMine.setMarquerMine(i, j);
    else if (champMine.estMarqueeMine(i, j)) champMine.setMarquerDoute(i, j);
    else if (champMine.estMarqueeDoute(i, j)) champMine.setMarquerNormale(i, j);

    barreUtil.updateDrapeaux(champMine.nbDrapeaux, champMine.nbMines);
  } // mousePressed()
예제 #2
0
  public void mouseReleased(MouseEvent e) {
    if (e.getButton() != MouseEvent.BUTTON1) return;
    if (!estDessus) return;

    JButton bouton = (JButton) e.getSource();
    i = champMine.getLingeBouton(bouton.getName());
    j = champMine.getColonneBouton(bouton.getName());

    if (champMine.getNbCasesDecouvertes() == 0) {
      champMine.creerGrille(i, j);
      champMine.mettreAJourVoisinage();
    }

    if (champMine.estMarqueeMine(i, j)) return;
    if (champMine.estUneMine(i, j)) {
      partiePerdue(i, j);
    }
    champMine.setDecouverte(i, j);
    barreUtil.updateDrapeaux(champMine.nbDrapeaux, champMine.nbMines);
  } // mouseReleased()