How to halt a java program until a method is called successfuly?
I'm doing a big project at the time - it can deal with history logs of a game.
In that project I created a method which returns logs within a given time - and it works very well.
I decided to create a UI for that program. Also I added a button which popups a JPanel to select date ranges - there's the problem start.
The popup pops out successfuly upon a butn click and user can select the date and submit. But I have methods which evaluates after that. What the problem is that the data from the popup is not submitted properly to the main program. I just debugged to find out what was happening. Then I found that the following methods evaluates before the popup pops out.
My question is how to halt the program until the user submits the dates and then again start the program. I m looking for a way like JS promises.
Not your answer but take a look at SwingUtilities invokeAndWait function. And probably you need to create a new thread (as you are already on Event dispatch thread) on button click to show JPanel.
Note: I have not done swing programming since quite long so it is as good as i don't know anything, but few things you do remember 😉