title: JButton Action Performed?
body: <p>I have created a Jframe/button with 10x10 grid. Each jbutton is apart of the grid. I am trying to how to affect each button pressed through JFrame/button, as I want to eventually make it into a battleships games.</p>
  
  <pre><code>frame.setLayout(new GridLayout(width,length));
              grid=new JButton[width][length]; 
              for(int y=0; y&lt;length; y++){
                      for(int x=0; x&lt;width; x++){
                              grid[x][y]=new JButton("("+x+","+y+")");     
                              frame.add(grid[x][y]);
                      }
              }
  </code></pre>
  
  <p>For example I am trying a basic piece of code to see if i can change the color of the Jframe to red by clicking it but it doesn't seem to be working.</p>
  
  <pre><code> public void actionPerformed(ActionEvent e){
             if( e.getSource() instanceof JButton) {
                 ((JButton)e.getSource()).setBackground(Color.red);
             }
          }
  </code></pre>
  
  <p>Anyone got any ideas? </p>