Hej.
class ProgressExample implements Runnable{
private final JProgressBar progressbar;
public ProgressExample() {
JFrame f = new JFrame("Example");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
progresbar = new JProgressBar();
progressbar.setMinimum(0);
progressbar.setMaximum(100);
f.getContentPane().add(progressbar);
f.pack(); f.setVisible(true);
// Start update in separate thread.
new Thread(this).start();
}
public void run() {
for (int i = 1 ; i < 100 ; i++) {
// Long operation to wait for.
try { Thread.sleep(100); } catch (InterruptedException e) {}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
progressbar.setValue(i);
}
});
}
}
}
Mvh
Parkenss