That looks a lot like JProgressBarDoesntUpdate That doesn't mean I disapprove of this entry; it's a generalization of the JProgressBar example which seems to never be found because, well, most people have the problem with other components. It's just funny to see how much similarities there are in the text. Kind of like quite a bit of copy-paste work.
Joined: Nov 18, 2006
It's similar but not the same. In the ProgressBar example it's very specific whereas I tried to formulate the text for all possible components. And the second huge difference is the use of SwingWorker in the new example, whereas in the old one the threading is handled directly. I thought that maybe the ProgressBar example was founded on a Java API that didn't provide SwingWorker (it's pretty new, you know).
Joined: Jun 09, 2010
thank you for your help I really appreciate it
however from the reading of swing worker it seems it is for jre 1.6
is there a way I can get it to work with1.4? There is no flush or a method I can call that repaint the whole thing
First of all thank you for the feedback. Its indeed helpful however I still have a question I am not sure which process to thread. As an example, I am reading the file line by line and I want to display it in the JTextArea. HOWEVER I want them to be synchronized. Meaning, I read a line, display, read next line display ..etc.
Do I start reading the lines one by one and start a thread (or swing worker) for each display update or the other way around? How Do I make sure that I read the next line after the display is done?
Sounds like work for a SwingWorker in combination with its pair of publish / process. In short, you publish any number of lines (probably one at a time) in your doInBackground() method. Then at some the process method is called in the EDT; the List will contain all non-processed lines so far; it's can contain the lines collected by multiple calls to publish. It won't be completely real-time but it's going to be as close as you're going to get.