Hi,
I've been working on a program which loads in large data files of the user's choosing during run-time. As these files can be quite large and take several minutes to load, I've been trying to use Swing's ProgressMonitor class to display a progress bar. This works fine as long as the code is set to loop, however if I use noLoop() (which I want to for processor performance reasons) the ProgressMonitor will show up blank on the second use. I've created a small demo to show what I mean:
Quote:
import javax.swing.ProgressMonitor;
void setup() {
size(200,200);
loadThing();
//noLoop(); //this causes the issue
}
ProgressMonitor prog = new ProgressMonitor(frame, "test","",0,2000);
void loadThing() {
//String loadPath = selectFolder(); //uncomment this for another error when noloop uncommented
int t0 = millis();
prog.setMinimum(t0);
prog.setMaximum(t0+4000);
while (millis() < t0+4001) {
prog.setProgress(millis());
}
}
void draw() {
rect(50,50,100,100);
}
void keyPressed() {
loadThing();
}
When running this in Processing, the first progress bar will work fine, however the second progress bar (initiated by pressing any key) will only display properly when noLoop() is not set. Note that it will operate properly and it will disappear after the 4 seconds it takes for its simulated load, however the graphics and cancel button will be absent.
Another issue I've stumbled upon (however I can work around by using custom Swing code instead of the new command) is that when noLoop() is set, you cannot call the new file chooser commands like selectFolder(). This can be seen by uncommenting the line above and seeing the resulting error.
Does anyone know a method to work around either of these issues while keeping the code operating in noLoop() mode? Any help is appreciated!
(P.S. What happened to "Copy for Discourse" in newer versions of Processing? I had to open the code in an older version to post this.)