title: Change JButton Color on ActionPerformed
body: <p>Despite my efforts of changing the color of my buttons, and reading everywhere on how to do it, my code still does not produce the desired effect. How can I change the color of a JButton
  when clicked? </p>
  
  <pre><code>public void generateButtons
  {
    //Global field
    firstBoard = new JButton[9][9];
  
          for(int x = 0; x &lt; firstBoard.length; x++)
          {
              for(int y = 0; y &lt; firstBoard[0].length; y++)
              {
                  firstBoard[x][y] = new JButton();
                  firstBoard[x][y].setActionCommand("0|" + (x + (firstBoard.length * y)));
                  firstBoard[x][y].addActionListener(this);
                  //firstBoardPanel.add(firstBoard[x][y]);
              }
          }
  }
  
  @Override
      public void actionPerformed(ActionEvent e)
      {
          if(e.getSource() instanceof JButton )
          {
              System.out.println(parseActionCommand(((JButton)e.getSource()).getActionCommand()));
              ((JButton)e.getSource()).setBackground(Color.BLUE); 
              ((JButton)e.getSource()).setContentAreaFilled(false);
              ((JButton)e.getSource()).setOpaque(true); 
          }
      }
  </code></pre>