I've created an array of buttons: 

```
JButton bt[][]=new JButton[8][8];

```

And then I call a function called `refreshBoard` in the following way

```
public void refreshBoard() {
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            bt[i][j] = new JButton(); 
            bt[i][j].setIcon(new javax.swing.ImageIcon("icons/"+ board[i][j] +".png"));
                panel.add(bt[i][j);   
        }
    }  

```

The value in `board[i][j]` controls which image is to be displayed on the button. I call this refreshBoard function at intervals. The problem is that when i call the function the second time it adds `64(8X8)` new buttons rather than replacing the already displayed ones. How do i make it replace the old buttons instead of adding new ones.