I had another question here and it was suggested me to make the program "modal" in order to block the program from running to the next line and "pausing" the program when a popup happened. I have tried it, but I do not understand how it works 100%.
Here's my code I tried to test with:
import javax.swing.*;
import java.awt.*;
public class test {
public static void main(String[] args) {
JFrame theDog = new JFrame();
theDog.setSize(200,200);
theDog.setVisible(true);
new JDialog(theDog,"theTitle", Dialog.ModalityType.APPLICATION_MODAL);
System.out.println("hello");
}
}
When the JPanel box pops up, it should "halt" the program until an action is taken there. For example, I want to have a button push based on a picture. I'm looking specifically to do this with a custom JPanel/JFrame, not using some JOptionPane get input dialog or anything like that.
When I run the code above, the system.out.println runs no matter what, even if I haven't closed the dialog box, it's like the program ignores the pop up. How can I halt and wait for a user action before taking the next move?
Here's the previous question I had asked with suggestions given: How Do You Halt The Current Programs "Progress" at A JPanel/JFrame Pop Up?