You did not pass the parent Window
and no modal
flag to the JDialog
’s constructor so the default behavior of modeless was used. Note that besides that your code is unnecessary complicated.
Since Java 6 you can pass a Window
to a Dialog
’s constructor and it is allowed to be null
so it is fail-safe. Combined with the existing method SwingUtilities.windowForComponent
the entire code may look like:
public class JProductStocking extends javax.swing.JDialog
implements BeanFactoryApp {
public JProductStocking(Component parent, Dialog.ModalityType modality) {
super(SwingUtilities.windowForComponent(parent), modality);
initComponents();
}
// …
Note that with the Java 6 Dialog.ModalityType
you can configure a Dialog
to block all other application’s windows besides the children of this dialog (APPLICATION_MODAL
) or to block the dialog’s parents and their children only (DOCUMENT_MODAL
). This provides much more control than the simple modal
flag.