swingworker

What is the rationale of SwingWorker?

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 a "normal" thread? Is not the same using a new Thread and when it finish invoke some GUI method using SwingUtilities.invokeLater?... What am I missing here? http://en.wikipedia....

How can I best implement a Fade Button Effect in Swing?

I have a JButton which, when pressed, changes background color from active to normal: final Color activeButtonColor = new Color(159, 188, 191); final Color normalButtonColor = new Color(47, 55, 56); I want to fade the active button color back to the normal button color when a specific task has finished executing. I'm using SwingWorke...

Pass data to swingWorker?

Is there a way to pass data e.g an object to the swingWorker before invoking "swingWorker.execute"? ...

How do I use SwingWorker in java?

Hi all With regards my question (http://stackoverflow.com/questions/772713/call-repaint-from-another-class-in-java). I'm new to java, and I've had a look at some tutorials on SwingWorker, but I'm unsure how to implement it with the example code i gave in the previous question. Can anyone explain how to use SwingWorker with regards my li...

Should I be using SwingWorker, threading or a recursive update for this animation?

Hi all. As I have said in my previous questions, I'm still new to java. I'm developing a tile based game in java. The movement is on a grid. I'm at the stage where I'm implementing character movement. My plan was, to use the code which I pasted in this question (http://stackoverflow.com/questions/772713/call-repaint-from-another-class-in...

How should I handle exceptions when using SwingWorker?

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 way of handling the exception? I'm particularly concerned about possible InterruptedExceptions. The JavaDoc example simply ignores the exception but I've lear...

Scheduling Swingworker threads

Hi, I have a 2 processes to perform in my swing application, one to fill a list, and one to do operations on each element on the list. I've just moved the 2 processes into Swingworker threads to stop the GUI locking up while the tasks are performed, and because I will need to do this set of operations to several lists, so concurrency wo...

How to prevent swing GUI locking up during a background task

Hi, I have a swing application which stores a list of objects. When the users clicks a button, I want to perform two operations on each object in the list, and then once that is complete, graph the results in a JPanel. I've been trying SwingWorker, Callable & Runnable to do the processing, but no matter what I do, while processing the l...

Swing: Can't get JButton to update - repaint() not working

I'm using Swing for the first time to create a simple GUI. It consists of a JFrame upon which I have placed a single JButton which, when clicked, calls some other code which takes approx. 3 seconds to return. Just before the call to this code, in actionPerformed(), I want to update the text on the button to inform the user that processi...

Swing application problem

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, but the central part of JFrame is invisible or hidden. After finishing some part of program logic the GUI repaints and is visible again. ...

Java Swing BasicUI update error, what can I do ?

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 error, what can I do ? ========================================================================= Exception in thread "AWT-EventQueue-0" java.lang.ArrayIn...

Swing: Passing a value back to the UI from a scheduled thread

I have a system tray UI in Java that requires a schedule database poll. What is the best method for spawning a new thread and notifying the UI? I'm new to Swing and it's threading model. ...

JDK-7 SwingWorker deadlocks?

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 (windows) but works in 6u16. It starts a new worker within another worker and waits for its result (the real app runs multiple sub-workers and waits fo...

Problem in javax.swing.SwingWorker

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 passed a JLabel reference of the GUI to the "Thread-Main". Now I have started 10 threads from the "Thread-Main". Now I want that all the 10 threads shou...

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

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 potentially large collections ? A criterion could be the actual running time, but what kind of number (in ms) would qualify ? ...

Java SwingWorker hanging

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 thread dump Java HotSpot(TM) Client VM (14.3-b01 mixed mode, sharing): "SwingWorker-pool-3-thread-4" prio=6 tid=0x07fd7c00 nid=0x143c waiting on condition [...

Swing Worker Modal Dialog Won't Close

I have a SwingWorker thread that launches a modal dialog box (from a property change listener that listens to the StateValue of started) and the swing worker proceeds to do its work. However, it looks like the done method is not called because that is called on the EDT but the swing worker's modal dialog is blocking the EDT. So, I can't ...

Making Java version of Notepad and I have a problem

I am trying to load all types of files (like Microsoft Notepad). The SwingWorker I have can load normal text just fine but when a file such as mp3, pdf, etc. is attempted to be loaded I receive a NullPointerException. Can someone take a look at my code and possibly see why I keep getting this error for files such as mp3, pdf, etc.? Lik...

Java InputReader. Detect if file being read is binary?

I had posted a question in regards to this code. I found that JTextArea does not support the binary type data that is loaded. So my new question is how can I go about detecting the 'bad' file and canceling the file I/O and telling the user that they need to select a new file? class Open extends SwingWorker<Void, String> { File fil...

How do you name a SwingWorker thread? Open to code or best practices

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 receiving. It doesn't seem possible to name a SwingWorker thread (is it?). I'm looking for any best practices or 'tricks' to help me properly identify my worker t...