import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class CompteEstBon extends JFrame{
private static String[] plaquettes={"1","1","2","2","3","3","4","4","5","5","6","6","7","7","8","8","9","9","10","10","25","25","50","50","75","75","100","100"};
private static int Total = (100 + (int)(Math.random()*(999-100))+1);
static Thread thread = new Thread();
public CompteEstBon() throws InterruptedException{
super("Compte est bon");
JPanel jpFond = new JPanel();
BorderLayout bl = new BorderLayout();
jpFond.setLayout(bl);
for(int i = 90; i>=0; i--){
thread.sleep(1000);
System.out.println(i);
}
Random r = new Random(System.currentTimeMillis());
int position1 = r.nextInt(plaquettes.length);
String nb1 = plaquettes[position1];
int position2 = r.nextInt(plaquettes.length);
String nb2 = plaquettes[position2];
int position3 = r.nextInt(plaquettes.length);
String nb3 = plaquettes[position3];
int position4 = r.nextInt(plaquettes.length);
String nb4 = plaquettes[position4];
int position5 = r.nextInt(plaquettes.length);
String nb5 = plaquettes[position5];
int position6 = r.nextInt(plaquettes.length);
String nb6 = plaquettes[position6];
JPanel jpNord = new JPanel();
jpNord.add(new JButton(nb1));
jpNord.add(new JButton(nb2));
jpNord.add(new JButton(nb3));
jpNord.add(new JButton(nb4));
jpNord.add(new JButton(nb5));
jpNord.add(new JButton(nb6));
jpFond.add(jpNord,BorderLayout.NORTH);
JPanel jpEst = new JPanel();
jpEst.add(new JButton(String.valueOf(Total)));
jpFond.add(jpEst,BorderLayout.EAST);
this.setContentPane(jpFond);
this.pack();
this.setVisible(true);
}
public void correction(){
}
}
J'ai ça comme code pour le compte à rebours
for(int i = 90; i>=0; i--){
thread.sleep(1000);
System.out.println(i);
}
Et ça me pose un probleme. En fait, il me lance le compteur, mais je dois attendre la fin pour que le reste se lance. Sauf que je ne vois pas où est le probleme.
Quelqu'un peut m'aider ?