title: Java game involving adjacent JButtons
body: <p>I'm making a small game involving a grid of JButtons (MxN) and the main premise is to click on <code>buttonA</code> and then on <code>buttonB</code>, coloring <code>buttonB</code> and adjacent buttons of the same color as <code>buttonB</code> with the color of <code>buttonA</code>. I have made it so you are able to choose 3 possible difficulties. The colors are randomly generated. The main problem is getting the colors to change.</p>
  
  <p>This is the method that I call after selecting the difficulty of the game:</p>
  
  <pre><code> public static void gameMechanics(int m, int n) {
      final String[] pickedColour = {""};
      final String[] placedColour = {""};
      JButton[][] picked = new JButton[m][n];
      JButton[][] placed = new JButton[m][n];
      picked[m][n].addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              pickedColour[0] = picked[m][n].getText();
          }
      });
      placed[m][n].addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              placedColour[0] = placed[m][n].getText();
          }
      });
      if (pickedColour[0] == "R" &amp;&amp; placedColour[0] != "R") {
          placed[m][n].setBackground(Color.RED);
          placed[m][n].setText("R");
      }
      else if (pickedColour[0] == "G" &amp;&amp; placedColour[0] != "G") {
          placed[m][n].setBackground(Color.GREEN);
          placed[m][n].setText("G");
      }
      else if (pickedColour[0] == "B" &amp;&amp; placedColour[0] != "B") {
          placed[m][n].setBackground(Color.BLUE);
          placed[m][n].setText("B");
      }
  }
  </code></pre>