I am trying to open up a bunch of JDialogs one after another. The goal is that only after one JDialog is closed the next one is created. I have tried to use setModal(true) for the dialogs, but somehow that does not make it work.
Just for you to get an idea, the code is roughly that:
for(Object o : mylist) {
JDialog j = new JDialog();
j.setModal(true);
}
The problem with that is that it opens up all the dialogs at once, so that multiple dialogs are open. How can I get what I want?
The following works for me. The below code displays a window containing a button with the text GO. When you click on the button, a
JDialogappears with the title 0 (i.e. the digit zero) and a button with the text Close. When you click on the Close button, theJDialogdisappears and anotherJDialogappears with the title 1 (i.e. the digit one) and a Close button. When you click on Close theJDialogdisappears and anotherJDialog, with the title 2 appears.showDialogsis called when the GO button is clicked.showDialogscreates a modalJDialog.setVisiblein the following line of code:Method
setVisibleonly returns after the modalJDialoghas been closed.JDialog) is clicked, methodcloseDialogis called.closeDialogdisposes theJDialog. Essentially theJDialogno longer exists after it has been disposed.showDialogs) is performed only after theJDialogit displays has been closed.