1 package net.sf.openrocket.util;
3 import java.awt.Component;
5 import javax.swing.ProgressMonitor;
6 import javax.swing.SwingUtilities;
10 * A thread-safe <code>ProgressMonitor</code>. This class may be instantiated
11 * and the method {@link #setProgress(int)} called safely from any thread.
13 * Why the FSCK&!¤#&%¤ isn't the default API version thread-safe?!?!
15 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
17 public class ConcurrentProgressMonitor extends ProgressMonitor {
19 public ConcurrentProgressMonitor(Component parentComponent, Object message,
20 String note, int min, int max) {
21 super(parentComponent, message, note, min, max);
25 public void setProgress(final int nv) {
27 if (SwingUtilities.isEventDispatchThread()) {
28 super.setProgress(nv);
31 SwingUtilities.invokeLater(new Runnable() {
35 ConcurrentProgressMonitor.super.setProgress(nv);
45 if (SwingUtilities.isEventDispatchThread()) {
49 SwingUtilities.invokeLater(new Runnable() {
53 ConcurrentProgressMonitor.super.close();