I don't know what I'm doing wrong, but I've looked at countless examples and can't seem to get it right. I have an application which extends JFrame and at the end of the constructor (just for testing, it won't stay there) I have the following code:
SwingWorker<Boolean, Integer> worker = new SwingWorker<Boolean, Integer>(){
protected Boolean doInBackground() throws Exception{
for(int i=0; i<1000000; i++) {
publish(i);
}
return true;
}
protected void process(List<Integer> chunks) {
for(int n : chunks) {
System.out.println(n);
}
}
protected void done() {
boolean status = false;
try {
status = get();
}catch(Exception e) {
}
}
};
worker.execute();
This is just to get a working example, eventually it will be to process tens of thousands of files which could take an estimate 30min to complete. So as such, I want it to run in the background. However, the application won't respond while it's running. Only thing I can do is move the window. What am I doing wrong?