Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you run heavy task in <a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html" rel="nofollow">The Event Dispatch Thread</a> it's gonna to freeze until finish to avoid that you can execute the download in another thread using <code>SwingWorker</code>. Follow this <a href="http://www.javacreed.com/swing-worker-example/" rel="nofollow">link</a> to see a complete example with <code>progressBar</code> , special attention to <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html#setProgress%28int%29" rel="nofollow">setProgress()</a> <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html#publish%28V...%29" rel="nofollow">publish()</a> and <a href="http://docs.oracle.com/javase/7/docs/api/javax/swing/SwingWorker.html#process%28java.util.List%29" rel="nofollow">process()</a>.</p> <p>Example:</p> <pre><code>public class MyWorker extends SwingWorker&lt;Integer, String&gt; { @Override protected Integer doInBackground() throws Exception { // Start publish("Start Download"); setProgress(1); // More work was done publish("More work was done"); setProgress(10); // Complete publish("Complete"); setProgress(100); return 1; } @Override protected void process(List&lt; String&gt; chunks) { // Messages received from the doInBackground() (when invoking the publish() method) } } </code></pre> <p>and in client code: </p> <pre><code> SwingWorker worker = new MyWorker(); worker.addPropertyChangeListener(new MyProgressListener()); worker.execute(); class MyProgressListener implements PropertyChangeListener { @Override public void propertyChange(final PropertyChangeEvent event) { if(event.getPropertyName().equalsIgnoreCase("progress")) { downloadProgressBar.setIndeterminate(false); downloadProgressBar.setValue((Integer) event.getNewValue()); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload