The core of the Java task in Swing

I need a very simple (skeletal) guide to progress indicators for developing a GUI in Java. The progress bar may be "vague" and ideally have an updated text label.

Here is some skeleton code, which I hope someone can expand just to make something work.

class MyFunView extends FrameView {

  // class vars and other stuff...

  @Action
  public void excitingButtonPressed() {

     /* I have n files to download */
     // Download file 1, set progress bar status to "downloading file 1"
     // ...
     // Download file n, set progress bar status to "downloading file 2"

  }

} 

Basically, how and why am I downloading the download code? (I understand that some subclass of Tasks is required?)

Thank you very much in advance.

EDIT:

We only have so much precious time to be alive, and no approach can be made in the form of small code or time, as I would hope, so I will not use the progress bar.

+3
source share
2

SwingWorker JProgressBar.

(, Runnable) JProgressBar. , , Swing EDT. SwingWorker . SwingUtilities.invokeLater. :

SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        progressBar.setValue(progressCounter++);
    }
});

, ? , SwingWorker PropertyChangeListener ...

+3

All Articles