In Java, you can make a JDialog modal by calling the setModal() method and passing in a boolean value of true.
Here's an example:
JDialog dialog = new JDialog();
dialog.setModal(true);
In this example, a new JDialog object is created and then the setModal() method is called with a value of true. This means that the JDialog will be modal, and it will block input to other windows in the same application until it is closed.
You can also make a JDialog modal when creating the object by passing in a boolean value of true to the JDialog constructor:
JDialog dialog = new JDialog(frame, "My Dialog", true);
In this example, the JDialog is created with a title of "My Dialog" and a boolean value of true, which makes it modal.
By default, a JDialog is non-modal, so it's important to explicitly set the modal property if you want to create a modal dialog box.