1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| import java.io.IOException;
import javax.swing.*;
public class JProgressBarIndexation extends JProgressBar{
private JProgressBar barreProgressionIndex;
private JFrame cadre;
private MoteurDeRecherche mdr;
public JProgressBarIndexation(MoteurDeRecherche mdr) throws IOException {
this.mdr = mdr;
cadre = new JFrame("Indexation en cours");
barreProgressionIndex = new JProgressBar(0, mdr.getRepTexte().list().length);
barreProgressionIndex.setValue(0);
barreProgressionIndex.setStringPainted(true);
add(barreProgressionIndex);
cadre.setContentPane(barreProgressionIndex);
}
public void setValeur(int compteur){
int val=(int)compteur*100/mdr.getRepTexte().list().length;
barreProgressionIndex.setValue(val);
}
public void updateBar(int newValue) {
barreProgressionIndex.setValue(newValue);
}
public void miseEnRoute() throws IOException{
cadre.pack();
cadre.setVisible(true);
for (int i = 0; i < mdr.getRepTexte().list().length; i++) {
final int percent = i;
mdr.getI().indexer(mdr.getRepTexte().listFiles()[i], mdr.getListeMotsOutils());
System.out.println("i="+i);
updateBar(percent);
// try {
/* SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateBar(percent);
}
});*/
/* java.lang.Thread.sleep(100);
} catch (InterruptedException e) {
System.out.println(e);
}*/
}
//mdr.getR().racinise(mdr.getRepIndex());
// System.out.println("termine");
cadre.dispose();
}
public static void main(String args[]) throws IOException {
MoteurDeRecherche mdr = new MoteurDeRecherche();
JProgressBarIndexation test = new JProgressBarIndexation(mdr);
test.miseEnRoute();
}
} |