I see the following code in a Java / Swing GUI project:
MyDialog dlg = new MyDialog(parent, isFizz);
MyDialogResults results = dlg.getResults();
eventBus.fireEvent(new MyDialogEvent(results));
In the code above MyDialog extends JDialog. Thus, a detailed dialogue is built (and somehow shown to the end user), and then, when the user exits the dialog box (by clicking the "OK" button or some other button), the resultsbean is used to start a new event on the event bus.
But I struggle with two things:
- How / where does Java say to actually draw / show a dialog to the user ?; and
- How / where does Java say to freeze / wait for the user to exit the dialog before triggering the event on the bus?
Is it that the child JDialogwill always show the dialog on creation JDialog, and not return from the constructor to exit the dialog? Here's a brief description of the hte constructor MyDialogabove:
public class MyDialog extends JDialog {
private boolean isFizz;
private MyDialogResults results;
public MyDialog(Frame parent, boolean isFizz) {
super(parent, "My Dialog", true);
setIsFizz(isFizz);
setVisible(true);
dispose();
}
}
Thanks in advance for any help / understanding with an understanding of how the dialog box opens, it hangs (although I know that it really wasn't hanging / frozen), closes, and then fires the event.
user1768830
source
share