swingworker

How to delegate SwingWorker's publish to other methods

My "problem" can be described by the following. Assume we have an intensive process that we want to have running in the background and have it update a Swing JProgress bar. The solution is easy: import java.util.List; import javax.swing.JOptionPane; import javax.swing.JProgressBar; import javax.swing.SwingWorker; /** * @author Savva...

What if a large number of objects are passed to my SwingWorker.process() method?

I just found an interesting situation. Suppose you have some SwingWorker (I've made this one vaguely reminiscent of my own): public class AddressTreeBuildingWorker extends SwingWorker<Void, NodePair> { private DefaultTreeModel model; public AddressTreeBuildingWorker(DefaultTreeModel model) { } @Override protected V...

Why is my GUI unresponsive while a SwingWorker thread runs?

Hello, I have a SwingWorker thread with an IOBound task which is totally locking up the interface while it runs. Swapping out the normal workload for a counter loop has the same result. The SwingWorker looks basically like this: public class BackupWorker extends SwingWorker<String, String> { private static String uname = null; private...

Executing SwingWorker from SwingWorker - waits until first one stops.

I'm trying to execute a SwingWorker (SubWorker) from another SwingWorker (MainWorker), and then I want the MainWorker to wait for the SubWorker to complete. In the mean time, the MainWorker should update itself according to property changes of the SubWorker. public class MainWorker extends SwingWorker<Void,Void> { public Void doInBa...

How can this SwingWorker code be made testable

Consider this code: public void actionPerformed(ActionEvent e) { setEnabled(false); new SwingWorker<File, Void>() { private String location = url.getText(); @Override protected File doInBackground() throws Exception { File file = new File("out.txt"); Writer writer = null; ...

Is this SwingWorker not reusing Threads in ThreadPoolExecutor?

As part of my Final Year Project I've developed a desktop application, which fits in the category of the "graphical IDE" if such a thing exists. I've implemented a little subset of Jessy James Garrett Visual Vocabulary for Information Architecture and Interaction Design, so the user can draw a diagram (a directed graph in other words) re...

Java GUI threads - SwingWorker

I have a question regarding SwingWorker and Java GUI's. I have several classes which process information, we can call them Foo1, Foo2, and Foo3. This processing can take a very long time. These are all subclasses of Foo, however Foo is not called directly itself (the Foo[x] classes use methods inherited from Foo. In order to keep the...

SwingUtilities.invokeLater()

How do I feel the essentialness of SwingUtilities.invokeLater() in any swing application.Please give some code example. ...

java swing worker thread to wait for EDT

I've got a worker thread that should wait for EDT to update the GUI before continuing execution. I've used the publish method to tell EDT to change something. How can i make the worker wait for that change to take place? ...

Is there a way to Start and Stop a SwingWorker more than once..??

I have a start and stop button. I was told that I must use a SwingWorker. The code that I have now works fine. I start it and I stop it. But what if i want to start it again..? I am reading that the doinBackground method will only be executed once. Is there a way to fire it off again..?? Right now I cannot create a new instance of that ...

Can I run one SwingWorker within another?

Hi, I need to run two SwingWorkers. One of them can only run after the other is done. Can I run them like this? class TestWorker { private FirstWorker worker1; private SecondWorker worker2; public TestWorker() { worker1 = new FirstWorker() { @Override protected void done() { ...

Java swing progress bar from EDT problem

This is for the swing experts out there. I have spent considerable time on this problem, so it is going to take me a few lines to explain the problem. I have a standalone java swing application (java 6). In my application, I have a frame with a radio button group. I have a single action linked to all the buttons in the group. The action...

Waiting for a cancelled future to actually finish

I have a SwingWorker which calls some code that does not check for thread interruption. After the call to worker.cancel(true), the worker.get() method will throw CancellationException immediately (as it is supposed to). However, since the background task's code never checks for its thread to be interrupted, it happily continues executi...

Swing Worker Threads Not Concurrent

Hi. It seems that when I instantiate 12 Swing Worker threads, the first six starts to complete its task, it finishes AND then the last six starts and finishes. The behavior I'm looking for is all 12 threads start working at the same time & finish at the same time. I have the following: for (int i = 0; i < 12; i++ ) { myTask m...

Swing/SwingWorker Beginer's question

Hi, I am trying to implement a GUI in java but I am beginner in swing. I want to make something clear. I read that in order to keep the GUI responsive I should use the SwingWorker class to do the task in a separate thread. Ok so far. No I have a model with around 15 methods that are remote methods. Each method returns different object ty...

Thread-confinement/swingworkers

I am not clear about thread confinement. In swing all the gui components must be updated through the EDT. SwingWorker is provided in Java6 for lengthy operations, and in the done method the gui components can be updated. My understanding was that the gui components in the done() method are updated in the EDT. Therefore there should be no...

backgrounds tasks by swingworkers become sequential

Hi, I am using SwingWorkers to make my GUI responsive. But I can not understand the following: I have a remote method I want to call from the GUI as the user presses a button. I have inside the action of the button (short for presentation of problem): //in action of button SwingWorker worker = new SwingWorker<boolean,Void>(){ @Over...

Architecture for displaying dynamic data in real time

Executive summary: What kinds of sound architecture choices are there for displaying thread-safe, dynamic data in real time using Swing? Details: I have recently completed writing a multi-threaded, automated trading platform in Java. I say "platform" because I have made it very easy to implement new and multiple trading programs by su...

Is there a way to pause/resume the SwingWorker

Is there a way to pause/resume the SwingWorker in Java ? ...

execute SwingWorker multiple times

I want to be able to use SwingWorker subclass multi times is this possible as I have read in the java doc "SwingWorker is only designed to be executed once. Executing a SwingWorker more than once will not result in invoking the doInBackground method twice." Any ideas? Thanks ...