I have built a gui around a stand-alone executable, which is an image processing algorithm, which should be run let us say 10 times, on different images.
Thus when pressing let us say the start-button, the program should be executed.
I can do this by Runtime.getRuntime().exec("thealgo.exe");
This works fine, since the results of the algorithm are succesfully written to disc. Also reading in these results for later use works correctly as well.
Yet I would like to update some parts of my gui, for example putting a label like "processing" or showing the current image being processed.
Yet this doesn't work!! The gui is only updated when all processing is finished, thus only when the loop is finished!!
To show what the problem is:
for (int i=0;i<10;i++) { try { Runtime runtime = Runtime.getRuntime(); String [] toRun={"cmd.exe","start","NBSinVis.exe"}; Process process = runtime.exec(toRun); process.waitFor(); runtime.freeMemory(); returnVal = process.exitValue(); process.destroy(); } catch (IOException ioe) { System.out.println(ioe); } catch (InterruptedException ie) { System.out.println(ie); } jLabel.setText("the new text " + i); }
Yet in this case only the last time the label would be updated.