Reputation: 427
Here is the code
void openFile_ActionPerformed(ActionEvent e) {
// some code here
worker.setFile(file);
worker.start();
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (actDone) {
if (timer != null)
timer.stop();
// How to return from the openFile_ActionPerformed() method after this line?
progressWindow.threadCompleted(worker);
}
}
};
timer = new Timer( 100 , taskPerformer);
timer.setRepeats(true);
timer.start();
progressWindow.display();
}
I want the method to return out of the openFile_ActionPerformed method after the line
progressWindow.threadCompleted(worker);
But this is inside an inner class. I tried to put "return;" there and it seemed to return from the method "actionPerformed()" in the inner class.
How to return out of the outer method from a method in an inner class? Thanks
Upvotes: 3
Views: 2215
Reputation: 83245
You can't do it.
The whole point of ActionListener.actionPerformed
is that it fires asynchronously, i.e. not stopping the flow of your program.
Your openFile_ActionPerformed
completes before actionPerformed
finishes.
Upvotes: 7