update text output (eg. jLabel) during calculations
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.