Good morning / afternoon / evening, lately I have had problems finding a solution for my problem what I try to do is pause a java program, this I used to do in C with sleep (milliseconds); and it worked as I wanted since the waiting time was done after the instruction that goes before of sleep but here in java I had problems I have dealt with Thread.sleep (milliseconds) and since I use it within actionPerformed, the waiting time is applied before executing the method, which I do not want. I would like to know if there is a way to apply the pause in the place I want, this is my code:
if(aux1.getIcon().toString().equals("f.jpg"))
aux1.setIcon(img[id]);
else
aux1.setIcon(new ImageIcon("f.jpg"));
if(turnos%2==0)
{
// Justo aquí es donde quiero la pausa, que lo de abajo tarde en realizarse.
if(aux1.getName().equals(aux2.getName()))
{
aux1.setVisible(false);
aux2.setVisible(false);
}
else
{
aux1.setIcon(new ImageIcon("f.jpg"));
aux2.setIcon(new ImageIcon("f.jpg"));
}
}
I hope you can help me because I really can not find a solution for this problem I have.