I am using a JAVA GUI in order to launch some C scripts. Such scripts take quite long time and I would like to implement a progress bar n the GUI that follows the C script progress. Just to put it simple I am using the following code to launch the process within the java program:
The program stampaCiao just print numbers from 1 to 10 sequentially (one every second). I would like to have in my jTextArea1 the number as long as they are generated. However the jTextArea1 is updated only when the process p ends completely. Is there a way to catch the output of stampaCiao in real time when is is generated instead of the end of the process?
BufferedReader reader = new BufferedReader( new InputStreamReader(p.getInputStream()) );
String line = null;
while( (line = reader.readLine()) != null )
thanks for your help!
If this code is in your Swing thread (ie the EDT) rather than a SwingWorker then it cannot update the test area until this code finishes, since the EDT is what does that updating. So launch this in a SwingWorker or similar.
thanks a lot for your reply. I am having a look at the SwingWorker class but it looks a bit complicated for my Java knowledges. Can you provide me with clean and simple example to achieve what you advised me in the last post please (or some link)?
Though you ought to run through the whole concurrency tutorial.