In my Swing GUI Java application, I would like to get the following.
There is a non-GUI thread doing some work. At some point, this stream requires input from the user before continuing. Then I would like to make some changes to the GUI, wait for a certain GUI action (for example, click OK), get the entered data from the GUI into a stream without a GUI and continue using calculation.
Looking around, I found a lot of information on how to initiate a task (long run) from a Swing GUI thread in another thread, but none of my problem.
SwingUtilites.invokeAndWait sounds like it is doing a task, but first it takes a Runnable argument instead of Callable , so there is no direct way to return the result, and secondly, it does not solve the problem of waiting for a specific GUI event.
I understand that I can make my own solution using, for example, a CountDownLatch , but for me the problem seems frequent enough to be a standard solution.
So my questions are: is this really a common problem, and if so, is there a solution in the standard library / libraries? If there is no standard solution, how would you solve it? If this problem does not occur often, why not?
source share