I made this code in java, I want to delay after this part of the code, but when I use the delay or sleep codes, all the code sleeps for the delay time, but I want to see that this leads to changes in gui and then make a delay !! ! so what should i do? (I use swing gui)
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (matrisBazi[i][j] == 0) {
jb[i][j].setBackground(Color.white);
}
if (matrisBazi[i][j] == 1) {
jb[i][j].setBackground(Color.red);
}
if (matrisBazi[i][j] == 2) {
jb[i][j].setBackground(Color.blue);
}
}
}
jb[i][j].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
click(s);
}
});
my actionPerformed void is called before and inside the click (); functions and makes this process how to add a swing timer code to this void ?! I think the timer does not work until it clicks (); finished.
source
share