Skip to content

Commit 197981b

Browse files
committed
8311881: jdk/javax/swing/ProgressMonitor/ProgressTest.java does not show the ProgressMonitorInputStream all the time
Reviewed-by: azvegint, tr
1 parent 04f39e1 commit 197981b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/jdk/javax/swing/ProgressMonitor/ProgressTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
*/
3131

3232
import java.io.InputStream;
33-
33+
import java.awt.EventQueue;
3434
import javax.swing.ProgressMonitorInputStream;
3535

3636
public class ProgressTest {
37-
37+
static volatile long total = 0;
3838
private static final String instructionsText =
3939
"A ProgressMonitor will be shown.\n" +
4040
" If it shows blank progressbar after 2048MB bytes read,\n"+
@@ -69,15 +69,20 @@ public int read() {
6969
public void run() {
7070
byte[] buffer = new byte[512];
7171
int nb = 0;
72-
long total = 0;
7372
while (true) {
7473
try {
7574
nb = pmis.read(buffer);
7675
} catch (Exception e){}
7776
if (nb == 0) break;
7877
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+
}
8186
}
8287
}
8388
};

0 commit comments

Comments
 (0)