Results 1 to 3 of 3
- 04-05-2011, 09:49 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
update text output (eg. jLabel) during calculations
Greetings all,
Average-experienced in Java here, and relatively new to Swing.
I am working on a tool that reads several files of raw data and makes heavy calculations upon pressing an "OK" button.
The calculation routine takes a while to complete (may go up to a couple of hours).
The final results are output in a jTextArea.
My problem is that I would like to see some updating on the gui, probably in the form of a jLabel, informing the user about the calculation stage, progress etc...
At first I naively added code within the flow, which puts some text inside a jLabel as soon as the calculations complete one stage (for example some boolean changing value). I soon realised that nothing is displayed within that jLabel until the entire calculation routine is complete, so the jLabel shows its text only when the jTextArea shows the final output.
Sure, while working on NetBeans, I can see in the output console that intermediate output by simple system.out.println() commands. But still, I would like to make it right so that a 3rd user can read the intermediate output with only the Gui.
I imagine that this might be asking for some event listener, but I can't seem to work my way through it. I would be grateful if you could point me at some direction.
Thanks very much in advance.Last edited by kosmo76; 04-05-2011 at 10:05 AM.
- 04-05-2011, 11:23 AM #2
You need to learn about SwingWorker and its publish and process methods.
Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing)
db
- 04-06-2011, 10:30 PM #3
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Problem about JLabel not update in JPanel
By fantasyme in forum Java AppletsReplies: 11Last Post: 10-16-2011, 07:00 AM -
update a jlabel
By niba10 in forum AWT / SwingReplies: 3Last Post: 04-04-2011, 07:43 PM -
Update JLabel during loop automatically
By carnado2008 in forum AWT / SwingReplies: 4Last Post: 01-22-2011, 02:55 PM -
Jlabel update problem
By fantasyme in forum AWT / SwingReplies: 3Last Post: 04-14-2010, 05:10 AM -
Problem altering text in JLabel
By porchrat in forum New To JavaReplies: 3Last Post: 06-29-2009, 12:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks