File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
test/jdk/javax/swing/ProgressMonitor Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 30
30
*/
31
31
32
32
import java .io .InputStream ;
33
-
33
+ import java . awt . EventQueue ;
34
34
import javax .swing .ProgressMonitorInputStream ;
35
35
36
36
public class ProgressTest {
37
-
37
+ static volatile long total = 0 ;
38
38
private static final String instructionsText =
39
39
"A ProgressMonitor will be shown.\n " +
40
40
" If it shows blank progressbar after 2048MB bytes read,\n " +
@@ -69,15 +69,20 @@ public int read() {
69
69
public void run () {
70
70
byte [] buffer = new byte [512 ];
71
71
int nb = 0 ;
72
- long total = 0 ;
73
72
while (true ) {
74
73
try {
75
74
nb = pmis .read (buffer );
76
75
} catch (Exception e ){}
77
76
if (nb == 0 ) break ;
78
77
total += nb ;
79
-
80
- pmis .getProgressMonitor ().setNote (total /(1024 *1024 )+" MB Read" );
78
+ System .out .println ("total " + total );
79
+ if ((total % (1024 *1024 )) == 0 ) {
80
+ try {
81
+ EventQueue .invokeAndWait (() -> {
82
+ pmis .getProgressMonitor ().setNote (total /(1024 *1024 )+" MB Read" );
83
+ });
84
+ } catch (Exception e ) {}
85
+ }
81
86
}
82
87
}
83
88
};
You can’t perform that action at this time.
0 commit comments