I have a problem, creating my Java frame application. I can't call repaint of component in a loop; This is the part of mo class:
if(e.getSource()==drop){
//check if the row has space
if(currentGame.isFull(choosePosition)){
return;
}
else{
int row = currentGame.placeFigure(choosePosition, turn);
ImageIcon temp;
if(turn)
temp = firstIcon;
else
temp = secondIcon;
for(int i = 0; i != row + 1; ++i){
cells[i][choosePosition].setIcon(temp);
if(i != 0)
cells[i - 1][choosePosition].setIcon(emptyIcon);
gameBoardPanel.repaint();
gameBoardPanel.revalidate();
Graphics myGraphics = getGraphics();
// Draw as appropriate using myGraphics
myGraphics.dispose();
paint(myGraphics);
try {
Thread.sleep(500);
} catch (InterruptedException ie) {
//Handle exception
System.out.println("can't start animation");
}
}
repaint();
}
}