title: How to swap colors of 2 objects
body: <p>Here's my code in question:</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Graphics;
  import javax.swing.JPanel;
  
  import sun.java2d.loops.DrawRect;
  
  import java.awt.event.MouseListener;
  import java.awt.event.MouseEvent;
  
  public class Board extends JPanel implements MouseListener
  {
  //instance variables
  private int width;
  private int height;
  private Block topLeft;
  private Block topRight;
  private Block botLeft;
  private Block botRight;
  
  public Board()  //constructor
  {
      width = 200;
      height = 200;
      topLeft=new Block(0,0,width/2-10,height/2-10,Color.RED);
      topRight=new Block(width/2,0,width/2-10,height/2-10,Color.GREEN);
      botLeft=new Block(0,height/2,width/2-10,height/2-10,Color.BLUE);
      botRight=new Block(width/2,height/2,width/2-10,height/2-10,Color.YELLOW);
      setBackground(Color.WHITE);
      setVisible(true);
      //start trapping for mouse clicks
      addMouseListener(this);
  }
  
  //initialization constructor
  public Board(int w, int h)  //constructor
  {
      width = w;
      height = h;
      topLeft=new Block(0,0,width/2-10,height/2-10,Color.RED);
      topRight=new Block(width/2,0,width/2-10,height/2-10,Color.GREEN);
      botLeft=new Block(0,height/2,width/2-10,height/2-10,Color.BLUE);
      botRight=new Block(width/2,height/2,width/2-10,height/2-10,Color.YELLOW);
      setBackground(Color.WHITE);
      setVisible(true);
      //start trapping for mouse clicks
      addMouseListener(this);
  }
  
  
  
  public void update(Graphics window)
  {
      paint(window);
  }
  
  public void paintComponent(Graphics window)
  {
  super.paintComponent(window);
  topRight.draw(window);
  topLeft.draw(window);
  botRight.draw(window);
  botLeft.draw(window);
  
  
  }
  
  public void swapTopRowColors()
  {
  Color temp = topLeft.getColor(topRight);
  topRight.setColor(temp);
  repaint();
   }
  
  public void swapBottomRowColors()
  {
  
  
  
  }
  
  public void swapLeftColumnColors()
  {
  
  
  
  }
  
  public void swapRightColumnColors()
  {
  
  
  
  }
  </code></pre>
  
  <p>How would I swap the colors of 2 of these "squares" using the <code>.getColor()</code> method? I'm thinking I'm on the right track to achieving it but haven't had to do something like this with colors before.</p>