Salut tout le monde,

Depuis une semaine, je galère dans un problème de barre de progression, je vous explique :

Je veux exécuter une commande ainsi :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
String[] command = new String[] {"C:\\mzWiff\\Debug\\mzWiff.exe", "--mzXML", "-v", "C:\\Directory\\" + wiffFile.getName()};
 
try {
 
   // executes the command
 
   Process pr = Runtime.getRuntime().exec(command);
 
   progressDialog = new ProgressDialog(frame,"Progress");
 
   progressDialog.displayTimeLeft = false;
 
   progressDialog.showAnimation = true;
 
   progressDialog.displayPercentageInProgressBar = true;
 
   progressDialog.beginTask("converting to mzXML", 100, true);
 
   // waits for the end of the process 
 
   System.out.print("Waiting...");
 
   // progressDialog = new ProgressDialog(frame,"Progress");
 
   new PrintStream(pr.getInputStream(),progressDialog).run();
 
   pr.waitFor();
 
   System.out.println("Done!");
   ...
Et voilà un bout du printStream() :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
public class PrintStream extends Thread{
 
 
 
/**
 
      * Methods that will retrieve the progress of MZWIFF 
 
      **/
 
        public PrintStream(InputStream is, ProgressDialog p) {
 
            __is = is;
 
            progressDialog = p;
 
       } 
 
 
 
 
         public void run() {
 
               ...
 
               // for example, n = 100, d = 5500, so x = 1 per cent.
 
               x = n*100/d;
 
            progress(x,100,getOldPercentage());
 
            ...
 
 
 
          public void progress(int percentage, int range, int oldPercentage) throws InterruptedException { 
 
               if(progressDialog.isCanceled()) {
 
                  System.out.println("CANCELED.");
 
                  progressDialog.finished
 
            }
 
            System.out.println(percentage + " of " + range + "\n");
 
            progressDialog.worked(percentage - oldPercentage);
 
            Thread.sleep(500); 
 
        }
 
}
et le programme fonctionne bien, le fichier de sortie est créé, voilà même ce qu'affiche ma cconsole java :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Waiting...
 
1 of 100 
 
3 of 100
 
4 of 100
 
...
 
69 of 100
 
Done!
 
70 of 100
 
...
 
97 of 100
 
 
99 of 100
Petit hic, la progress bar ne s'affiche que lorsque le processus est terminé (lorsque done! s'affiche)...

Quelqu'un aurait il une solution?