I want to make a method wait until an ActionEvent method has processed before continuing.
Example:
public void actionPerformed(ActionEvent evt) {
someBoolean = false;
}
the actionPerformed method is linked to a textField I have, and the method is triggered when you press Enter. What I want to do, is have a different method pause until the actionPerformed method happens.
Example:
public void method() {
System.out.println("stuff is happening");
//pause here until actionPerformed happens
System.out.println("You pressed enter!");
}
Is there a way to do this?
CountDownLatch should do the trick. You want to create a latch waiting for 1 signal.
Inside the actionPerformed you want to call countDown() and inside “method” you just wanting to await().
-edit-
I’m assuming that you’ve already got the right amount of Threads set up to handle the situation.