Can a progress bar be used in a class outside main?

SwingWorker is ideal for this. The example below performs a simple iteration in the background, while reporting progress and intermediate results in a window. You can pass whatever parameters you need in a suitable SwingWorker constructor. import java.awt.EventQueue; import java.awt.GridLayout; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.text.DecimalFormat; import java.util.List; import javax.swing.*; /** @see http://stackoverflow.com/questions/4637215 */ public … Read more