SwingWorker « Thread « Java Swing Q&A





1. What is the rationale of SwingWorker?    stackoverflow.com

For what I can read, it is used to dispatch a new thread in a swing app to perform some "background" work, but what's the benefit from using this rather than ...

2. How should I handle exceptions when using SwingWorker?    stackoverflow.com

I use SwingWorker in Java 6 to avoid running long-running code on the event dispatch thread. If the call to get() in my done() method returns an exception, what is an appropriate ...

3. SwingWorker cancellation with ThreadPoolExecutor    stackoverflow.com

i am using a ThreadPoolExecutor with a thread pool size of one to sequentially execute swing workers. I got a special case where an event arrives that creates a swing worker ...

4. Swing application problem    stackoverflow.com

I'm developing Swing application, and everything works fine usually. But I have an GUI issue. When I run the application, and for example minimize some other window, my application is still working, ...

5. Java Swing BasicUI update error, what can I do?    stackoverflow.com

My program uses Swing JPanel, JList, JScrollPane ... It runs fine, but generated the following error message, and yet in the message it didn't say which line of my program caused the ...

6. Using SwingWorker publish efficiently    stackoverflow.com

I am using SwingWorker to query a server process for a large number of "result" objects on a background thread. As individual results arrive I want to publish them and ...

7. JDK-7 SwingWorker deadlocks?    stackoverflow.com

I have a small image processing application which does multiple things at once using SwingWorker. However, if I run the following code (oversimplified excerpt), it just hangs on JDK 7 b70 ...

8. Problem in javax.swing.SwingWorker    stackoverflow.com

I have made a swings application but there is one problem in that which is as follow: I have initiated a SwingWorker thread named "Thread-Main" from the Event Dispatch Thread and have ...

9. What should qualify as a "long running task" to be executed in a SwingWorker thread?    stackoverflow.com

I know how to use SwingWorker threads, but I still don't have precise criteria to decide when to use one or not. I/O seems obvious, but what about methods operating on ...





10. Java SwingWorker hanging    stackoverflow.com

I'm debugging some code that was written using a SwingWorker to perform a mix of numerical calculation and GUI update. The SwingWorker hangs with the following stack trace :

Full ...

11. How do you name a SwingWorker thread? Open to code or best practices    stackoverflow.com

I'm trying to debug a horrible exception that is occurring in a SwingWorker thread. If I could name my SwingWorker threads, then I could better interpret the stack traces I am ...

12. Java GUI and Multiple Instances of the SwingWorker Class    stackoverflow.com

I'm making a GUI using Java (who isn't?). I know the Swing Worker class enables computation in the background to prevent the GUI from hanging, but I was wondering if ...

13. Make GUI more responsive    stackoverflow.com

The program I have visualizes a physics simulation (basically). Right now, it works, but can get very unresponsive, and I think I know why - too much (read:all) computation is ...

14. Does SwingWorker has to be a nested class?    stackoverflow.com

I'm wondering if SwingWorker has to be a nested class within my main GUI. I'd rather make it an external class to keep the GUI clear from any of my programs ...

15. Swingworker producing duplicate output/output out of order?    stackoverflow.com

What is the proper way to guarantee delivery when using a SwingWorker? I'm trying to route data from an InputStream to a JTextArea, and I'm running my SwingWorker with the execute ...

16. Java - SwingWorker - problem    stackoverflow.com

I am developing a Java Desktop Application. This app executes the same task public class MyTask implements Callable<MyObject> { in multiple thread simultaneously. Now, when a user clicks on a "start" button, ...





17. How can this SwingWorker code be made testable    stackoverflow.com

Consider this code:

public void actionPerformed(ActionEvent e) {
    setEnabled(false);
    new SwingWorker<File, Void>() {

        private String location = url.getText();

  ...

18. Java GUI threads - SwingWorker    stackoverflow.com

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 ...

19. Can I run one SwingWorker within another?    stackoverflow.com

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 ...

20. Swing/SwingWorker Beginer's question    stackoverflow.com

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 ...

21. Thread-confinement/swingworkers    stackoverflow.com

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 ...

22. Architecture for displaying dynamic data in real time    stackoverflow.com

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 ...

23. How to abort a already-started swing worker thread?    stackoverflow.com

If I have started a SwingWorker thread by invoking its execute(). Is there any way that I can interrupt it at its execution?

24. java launching multiple swingworkers from the same UI    stackoverflow.com

Brief description of UI and setup 1)Plain vanilla frame, with button1 and button2 and textarea1 and textarea2 2)Button1 launches a continuous running task using a swingworker myswingworker1 and the swingworker's process method continually ...

25. Java 5 SwingWorker replacement    stackoverflow.com

Our Swing application performs some long-running tasks in a background thread using the excellent SwingWorker class. However, a lot of older Macs only support Java 5, so we want to compile ...

26. cookie persistence with DefaultHttpClient and Swingworker    stackoverflow.com

I have a swingworker class calling a method that uses DefaultHttpClient to establish a persistent connection to a secure web site. After I login and make a request to the ...

27. How to create a resizable rectangle in java swing?    stackoverflow.com

I'm repeating same que, i need to create a rectangle which is resizable, in java swing. How do i do it? Please help. Thanks in advance. -Uday

28. setvisible method in java swing hangs system    stackoverflow.com

I have banking gui application that I am currently working on and there seems to be a problem with the setvisible method for my jdialog. After the user has withdrawn a ...

29. How to free up memory allocated by a Swingworker?    stackoverflow.com

My program uses several Swingworker threads and I need to free up each thread's memory after it completes. Whether my thread terminates by completing the doInBackground() method or gets stopped by ...

30. java GUI frozen when downloading file    stackoverflow.com

public class download {
    public static void Download() {
        final String saveTo = System.getProperty("user.home").replace("\\", "/") + "/Desktop/";
     ...

31. Swing pseudo-blocks upon launching a Thread OR a SwingWorker that does computation    stackoverflow.com

I have a very simple application with a very strange behaviour. It's essentially the SwingWorker example, but when I press the button the GUI behaves just like the EDT is being blocked. ...

32. Problem implementing Java Swing worker    stackoverflow.com

I've just learned about executing swing background tasks and I'm starting to experiment with it but I'm having a little trouble with implementation. My code retrieves an image ...

33. SwingWorkers stopped working    stackoverflow.com

I'm having a very strange problem. I was working on an application using Swing, and of course I'm using SwingWorkers. They were working porperly until last night. I just ran the ...

34. Why Eclipse plugin code is not able to invoke a swingworking thread from an external java swing application?    stackoverflow.com

I have implemented a standalone java application which uses the swing framework for GUI.As part of the GUI there is a JTextArea which appears after a button is clicked on and ...

35. How cancel the execution of a SwingWorker?    stackoverflow.com

Currently I have two SwingWorker threads doing job on background. If an exception occurs, the method stop to work, but the thread still runnig. How I do to stop the execution ...

36. SwingWorker: when exactly is called done method?    stackoverflow.com

Javadoc of the done() method of SwingWorker:
Executed on the Event Dispatch Thread after the doInBackground method is finished. I've clues that it is not true in the case of canceled worker.
Done is ...

37. Java SwingWorker Socket Server does not get cancelled when i cancel the the SwingWorker    stackoverflow.com

I got a Socket Server running as a Java SwingWorker. The SwingWorker receives incoming connections, and upon connection, hands over the socket to an Executor that takes care of the connection. ...

38. What threads are allowed to call SwingWorker#publish?    stackoverflow.com

Standard scenario: User presses button and starts big task. EventThread creates SwingWorker to execute the task and get's on with life. Now, since the big task is highly parallelizable, the first thing ...

39. Gracefull exception handling in Swing Worker    stackoverflow.com

I am using threading in application through Swing Worker class. It works fine, yet I have a bad feeling about showing an error message dialog in try-catch block. Can it potentially ...

40. How to trigger a dialogue box with a SwingWorker (External Class)    stackoverflow.com

I've been trying to familiarize myself with the use of SwingWorkers in Java. Is it possible to trigger a dialogue box to display from the GUI within a SwingWorker's process method? ...

41. Swingworker Timeout    stackoverflow.com

I am using a SwingWorker to read data over a TCP connection and display when it comes back.

new SwingWorker<EnvInfoProto, Void>() {
  @Override
  public EnvInfoProto doInBackground() {
    ...

42. Different object of stateful session bean using SwingWorker in Java Swing    stackoverflow.com

I have a have a custom progressbarpanel in Swing where I want to show the progress of a lengthy operation. So I created two swingworkers:

  1. One that does the actual lengthy operation in ...

43. How do I read a SwingWorker's result *without* busy wait?    stackoverflow.com

I'm writing an application that executes its file menu actions using SwingWorker. Every called method returns a boolean value that tells, whether the operation was successfully executed or not. At the moment ...

44. How to tell someone about importance of SwingWorker?    stackoverflow.com

My colleague asked me about importance of SwingWorker. I said following: SwingWorker is useful for performing a time-consuming task in response to some event like button press. If we do not use ...

45. Update UI using swingworker thread    stackoverflow.com

I want to use the swing worker thread to update my GUI in swing. pls any help is appreciated.I need to update only the status of 1 field using the thread ...

46. WatchService and SwingWorker: how to do it correctly?    stackoverflow.com

WatchService sounded like an exciting idea ... unfortunately it seems to be as low-level as warned in the tutorial/api plus doesn't really fit into the Swing event model (or I'm missing ...

47. Does Java have built-in "reversed" SwingWorker    stackoverflow.com

SwingWorker lets you prepare some data in a background Thread and then use it in EDT. I am looking for a utility that does the opposite: Prepare data in EDT, and ...

48. How can I pass arguments into SwingWorker?    stackoverflow.com

I'm trying to implement Swing worker in my GUI. At the moment I have a JFrame containing a button. When this is pressed it should update a tab displayed and then ...

49. SwingWorker, update gui without calling repaint    stackoverflow.com

Im trying to use the SwingWorker to update my gui without calling repaint(). The program compiles but isn't responsive to the updates of the SwingWorker as I thought, unless I call repaint(). ...

50. SwingWorker gui repaint    stackoverflow.com

Im trying to use the SwingWorker to update my gui without calling repaint(). I want the SwigWorker to update the status of each GridGraphic[i][j] and the have the gui be repsonsive to ...

51. Stop/cancel SwingWorker thread?    stackoverflow.com

I'm trying to find out how to stop a SwingWorker thread from running when I press a button. I have been looking around and I'm having some trouble working out how ...

52. Subtype SwingWorker: where would I place my statements that would not run in the GUI thread    stackoverflow.com

I have created a subtype of SwingWorker and I wanted to know where would I place my statements that would not run in the GUI thread. Note: this is a simple SwingWoker ...

53. SwingWork chaining    stackoverflow.com

I am in a process of improving usability of a Swing application. I am trying to add SwingWorks to offload some of the DB and IO calls that were running ...

54. SwingWorker    coderanch.com

55. Producer/Consumer using SwingWorker    coderanch.com

Hi all, Questions about Thread. Does anybody can help me regarding Producer/Consumer using SwingWorker ? Here is the background. I'm developing a Java program, Swing based, which : a). check every, say, 30 sec if a file within a directory exists b). if exists, the process it ( this could be time-consuming task ). c). run a query every, say, 60 ...

57. SwingWorker    coderanch.com

59. HFDP p. 465: Why using SwingWorker when we can instead use a Virtual Proxy?    coderanch.com

Is the following proxy thread safe : . package headfirst.proxy.virtualproxy; import java.net.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; class ImageProxy implements Icon { ImageIcon imageIcon; URL imageURL; Thread retrievalThread; boolean retrieving = false; public ImageProxy(URL url) { imageURL = url; } public int getIconWidth() { if (imageIcon != null) { return imageIcon.getIconWidth(); } else { return 800; } } public int ...

60. Help on SwingWorker    coderanch.com

Hi Everyone, I wanted to understand the way SwingWorker is used. All i know is that it is used to perform some task in the background thread so that the GUI does not Freeze. i want to know HOW-TO actually use the SwingWorker class. To make my question a little more clear i will put forth a simple application where SwingWorker ...

61. SwingWorker Threads    coderanch.com

62. SwingWorker inside SwingWorker    coderanch.com

Hi, What is the correct way to do the following? I've got a panel which is a typical search criteria and results form. Before doing setPanel(myPanel), I need to populate a combobox with values from the db and then populate a table with results also coming from the db. The method to populate the table first gets the select combobox item ...

63. Swing worker thread    coderanch.com

Java newbie here with a worker thread problem. I'm trying to receive streaming audio via UPD and when the program enters the for loop in the worker thread, it hangs and the event thread becomes unresponsive. If I comment out the for loop, all is ok. Commenting out the audioPlayer line with the for loop uncommented makes no difference as long ...

64. Ending SwingWorker after cancel    coderanch.com

Hi everyone, I am doing a small mail program to allow a user to send an attachment from the main program. I have created a method called send() in which all the necessary javamail methods are used to provide data about the delivery such a SMTP host etc. The send method is then used in SwingWorker because when the user clicks ...

65. SwingWorker and Communications with GUI    coderanch.com

Hi Folks, I'm writing an app that schedules a list of jobs to be sent to a ray tracer each job may take an hour or more so, I have a list of jobs, I want to do them one at a time, not all together the ray tracer gives info on what it's doing that I'd like to post to ...

66. Observe Folder with Swing Worker Thread    coderanch.com

Hi guys. I'm new to Swing and currently I'm having some problems. I want to observe a certain folder, and whenever a new image file is copied to it or created in the folder, i want to display it in my Swing Application. So far I've made a simple app with a panel and an ImageIcon which I've read from the ...

67. Using SwingWorker    coderanch.com

Hello folks, I'm trying to get my head around SwingWorker, I'm creating a fairly simple vending machine application. And I've identified the following use cases Start: Message = "MACHINE READY" Keypad pressed (change>0 && prodcode.length<=2): append to product code, update message with Balance: xx Product: x Enter pressed (change>0 && code.length>1): check money inserted, check code is valid, check slot for ...

68. Swing Worker    coderanch.com

69. Can I catch an out of memory error inside a SwingWorker thread    coderanch.com

Hi All, I'm not sure if this is the right forum for this question. If not, I apologize... but my question is: I have a java app that uses a SwingWorker to process image information pixel by pixel and covert this information into other object that my app requires. Now, depending on the size of the image, this could be a ...

70. Java 1.6.0.20 broke my SwingWorker threads!    coderanch.com

I was previously running Sun Java 1.6.0.16 and have been designing a Swing GUI for use on my team at work. Everything was working great and my teammate and I were going to release the initial version to our team for testing next week. However, today I updated from 1.6.0.16 to 1.6.0.20 and now my worker threads don't seem to properly ...

71. How to catch an exception from a SwingWorker    coderanch.com

class LaunchButtonListener implements ActionListener{ Class target; public LaunchButtonListener(Class c) { target = c; } public void actionPerformed(ActionEvent e) { if (Runnable.class.isAssignableFrom(target)) { try { Runnable r = (Runnable) target.newInstance(); LaunchWorker lw = new LaunchWorker(r); lw.execute(); } catch (Exception ex) { System.out.println("Error launching " + target); } } else { System.out.println("Target class not Runnable"); } } } class LaunchWorker extends SwingWorker ...

72. SwingWorker causes problem    coderanch.com

73. When would I use a SwingWorker and why are all the videos in Chinese?    coderanch.com

Hello, I've read the entire lesson on concurrency. http://download.oracle.com/javase/tutorial/essential/concurrency/ I understand most of this.. I read SwingWorker, http://download.oracle.com/javase/tutorial/uiswing/concurrency/worker.html I didn't really understand it. So, I went looking for videos. They're all in Asian languages. I have questions about things.... 1. When would I use a swing worker instead of a Thread, or a Timer object? 2. How does one implement a ...

74. SwingWorker problem!!! How can I run it 2 times or more?    java-forums.org

Hello!! I am new in Java. I use the following code: SwingWorker SWorker = new SwingWorker() { public String doInBackground() { return CargarInformacion(); } public void done() { try { JTextAreaReport.append(get()); } catch(InterruptedException ie){ System.out.println(ie.toString()); } catch(java.util.concurrent.ExecutionException ee){ System.out.println(ee.toString()); } } }; private String CargarInformacion() { try { in = new BufferedReader(new FileReader(file)); } return StrMessage; } The ...

75. SwingWorker and my small internet page downloader    java-forums.org

I wrote this code to understand the processes of SwingWorker class which i have been trying to implement. I want to know is this right way to use SwingWorker or not ? Java Code: import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.concurrent.ExecutionException; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import ...

76. SwingWorker Opinions    java-forums.org

I have written a console program in java that reads a rather large (un-formatted) text file and formats it. I wrote a class called FormatText which creates a new thread and formats the text while another Thread, ( the controller ) thread can report updates. Anyway, long story short, I have updated the program to a GUI with swing and I ...

77. swingworker    java-forums.org

Hey Guys Am sending data to the serial port a byte at a time and a response is recieved at the serialport for every sent byte. My problem is that all the responses are displayed in the application after all the bytes are sent. I want each response to be shown in the application when it's recieved and not after all ...

78. How to stop SwingWorker?    java-forums.org

Good day everybody! I need a piece of advice on how to stop SwingWorker because using cancel(true) method doesn't work out. Here's the outline: everyting runs fine. When I push the button on the UI (i.e. call the cancel(true) method) the program keeps running as if nothing has happened and runs safely till the very last calculation. Furthermore, I've inserted a ...

79. Popup usage: SwingWorker Threads?    java-forums.org

Hi, I need to popup a warning message if an exception gets caught within the SwingWorker thread I'm currently using. Since it's my understanding that I shouldn't be making component/GUI updates/changes from outside the event dispatcher thread what's the best way to do this? I'm thinking it might have something to do with the firePropertyChange method and creating my own property ...

80. SwingWorker problem    java-forums.org

Hi, I am trying to download from a URL from my website an mp3, while updating a progress bar. Please see below section of code - some of it may seem irrelevant such as System.out.println's but I am trying to see what it is doing. The local file IS created, it does read the first set of bytes from the URL ...

81. Copying an mp3 from url to local file within swingworker    java-forums.org

Please see below code snippet. It does work when copying a .GIF and .PHP, but when I try to copy an MP3 it continues for a while and then stops (does not complete the download), I am guessing that MP3 files do not have carriage returns in them (not sure if this is true or relevant) , any help would be ...

82. Using thread pools with SwingWorker?    java-forums.org

Hey all, I am attempting to use multi-threading with Swing, and I am running into some problems. For one, I learned that you have to do everything on the EDT when working with Swing, and that using any other threads could lock up the UI. However, I also started looking into SwingWorkers. I might be misunderstanding this, but it seems that ...

83. When do I use SwingWorker?    java-forums.org

I am programming a game loop for my, well, game. Duh. I was originally using threads to control this, but soon discovered that Swing is not thread safe. I was lead to SwingWorker, which does whatever task in the background and then updates it on the EDT. This would be great for something like a progress bar, UI, text etc. I ...

84. SwingWorker progress?    java-forums.org

Since you don't know the time remaining, I can't see how you'll be able to pass it anywhere. Perhaps you are able to get another surrogate marker of completeness such as bytes or files processed? Otherwise about all that I can see you can do based on the code and information provided is to tell the calling code when the SwingWorker ...

86. Clean Way to Give Standalone Swingworker Access to GUI Control Methods?    forums.oracle.com

Hi All: I am fairly new in Swing GUI programming. Is there a good way to give Stand alone Swingworker class GUI control methods I have written? In all the SwingWorker example I have encountered people seems to adopt the practice of embedding the whole SwingWorker class inside the Swing GUI code so that the SwingWorker can access the variables of ...