I used this code to try and make the JButtons in my project (chess game) transparent so you can only see the piece and not the background. It works but the buttons copy themselves when I move my mouse over the board. E.g. If I have my mouse on a piece with a pawn and then move to a piece with a knight on it the pawn will appear behind the knight. Repainting the frame gets rid of them, but even if I repaint on mouse move it still looks really odd when I move around the board.
public class Pawn extends JButton(){
Pawn(x, y){
this.setIcon(new ImageIcon("pawn"));
this.setBounds(x, y, 100, 100);
this.makeClear();
}
public void makeClear(){
this.setOpaque(false);
this.setContentAreaFilled(false);
this.setBorderPainted(false);
}