i was been trying to do a chess game and got stuck on swaping two piecess
this is my ChessSquare class
   public class ChessSquare extends JButton 
{ 
public int Yposition;
public int Xposition;
private String Type;
public ChessSquare( Icon s, int y , int x , String piece )
{
 super(s);
 Yposition = y;
 Xposition = x;
 Type = piece ;
}         
public int getXposition()
 {
   return this.Xposition;
 }  
    public int getYposition()
 {
   return this.Xposition;
 }  
    public String getType()
   {
      return "";
   }
 }  
then i add this to the ChessBoard class, using the ChessSquare class as 2D array
     public class ChessBoard extends JFrame implements ActionListener
  {
     String type;
     ChessSquare[][] s = new ChessSquare[8][8];
     int xPos1,xPos2,yPos1,yPos2,i,j;
     JPanel panel;
    ........
    public void actionPerformed(ActionEvent e)
  {
       Boolean flag = false ;
         if(!flag)
  {
     xPos1 = s.getYposition();
     yPos1 = s.getXposition();
     flag = true;
   }
     else
   {
    xPos2 = s.getYposition();
    yPos2 = s.getXposition();
    s[xPos1][yPos1] = s[xPos2][yPos2];
    s[xPos2][yPos2] = s[xPos1][yPos1];
    flag = false;
 }
 }
 } 
trying to swap two pieces...but its not working? please help...
