Skip to content

Commit

Permalink
8311881: jdk/javax/swing/ProgressMonitor/ProgressTest.java does not s…
Browse files Browse the repository at this point in the history
…how the ProgressMonitorInputStream all the time

Backport-of: 197981b431fb7c7e6740ac45a671b99d1c7583c6
  • Loading branch information
GoeLin committed Apr 10, 2024
1 parent 8173c64 commit e0d2248
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/jdk/javax/swing/ProgressMonitor/ProgressTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
*/

import java.io.InputStream;

import java.awt.EventQueue;
import javax.swing.ProgressMonitorInputStream;

public class ProgressTest {

static volatile long total = 0;
private static final String instructionsText =
"A ProgressMonitor will be shown.\n" +
" If it shows blank progressbar after 2048MB bytes read,\n"+
Expand Down Expand Up @@ -69,15 +69,20 @@ public int read() {
public void run() {
byte[] buffer = new byte[512];
int nb = 0;
long total = 0;
while (true) {
try {
nb = pmis.read(buffer);
} catch (Exception e){}
if (nb == 0) break;
total += nb;

pmis.getProgressMonitor().setNote(total/(1024*1024)+" MB Read");
System.out.println("total " + total);
if ((total % (1024*1024)) == 0) {
try {
EventQueue.invokeAndWait(() -> {
pmis.getProgressMonitor().setNote(total/(1024*1024)+" MB Read");
});
} catch (Exception e) {}
}
}
}
};
Expand Down

1 comment on commit e0d2248

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.