You have two options:
Use static methods in JOptionPane. They will create modal dialogs by default:
Window parentWindow = SwingUtilities.getWindowAncestor(parentPanel);
JOptionPane.showMessageDialog(parentWindow, "Hello, World); // Create modal dialog aligned with parent window.
Create JDialogexplicitly:
Window parentWindow = SwingUtilities.getWindowAncestor(parentPanel);
JDialog dlg = new JDialog(parentWindow, ModalityType.APPLICATION_MODAL);
, .