How can you create a function or component, etc., that will stop all current code until the condition is met?
For example, the same as JOptionPane, if I have this, for example:
JOptionPane.showInputDialog(null, "Hello", "Title", 1);
Inside the function, etc., and then after that print to the console, it will not print until I close JOptionPane.
I suppose this component has some kind of stream setting built in for this, but how can I duplicate this with my own functions?
So say, for example, I wanted JFrames to delay everything until it was closed, so it acts like a JOptionPane.
Or, for example, there is a function that had several inputs that were updated, and inside it some mathematical calculations were performed with them, and if it were a certain value, the returned logical value, but then everything else, but they were suspended until then until the true boolean returns.
I suppose the solution is some kind of thread setup, but I'm pretty new to Java, and when I encoded in the past, I really didn't use streams, so I can't create a good system stop-start / pause-run style function yet .
Does anyone have any suggestions on how to achieve this or better, but code examples showing how this type works?