title: How would I add an action listener to buttons on a loop?
body: <p>I want it so every time a button is pressed in my 4x4 grid, that it increments <code>moves</code> by 1 . This is creating a 4x4 layout of buttons. Each time any of those buttons are pressed, I want <code>moves</code> to increment. Basically I'm creating the memory game, where you flip cards over to match each other. I just have to keep count of the total amount of <code>moves</code> a player does to solve the puzzle.</p>
  
  <pre><code>private int moves = 0;
  
  private GridPane makeGridPane(){
      ConcentrationModel c = new ConcentrationModel();
      GridPane grid = new GridPane();
  
      ColumnConstraints col1 = new ColumnConstraints();
      col1.setPercentWidth( 50 );
  
      grid.getColumnConstraints().addAll(col1, col1, col1, col1);
      RowConstraints row1 = new RowConstraints();
      row1.setPercentHeight( 50 );
      grid.getRowConstraints().addAll(row1, row1, row1, row1);
  
  
      for(int row = 0; row &lt; 4; row ++){
          for(int col = 0; col &lt; 4; col++){
              Button btn = new Button();
              ImageView image = new ImageView(c.getCards().get(0).getImage());
              image.setFitWidth(WIDTH/4);
              image.setFitHeight(HEIGHT/4);
              btn.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
              btn.setGraphic(image);
              grid.add(btn, col, row);
  
  
          }
      }
      return grid;
  }
  </code></pre>