JDialog#setModal 的用途

Purpose of JDialog#setModal

d.setModal(true); 的目的是什么?

public DatePicker(JFrame parent) {
    dialog = new JDialog();
    dialog.setModal(true);

    String[] header = { "Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat" };

    JPanel panel = new JPanel(new GridLayout(7, 7));
    panel.setPreferredSize(new Dimension(430, 120));

    ...
}

我曾尝试在 Whosebug 上进行搜索,但没有找到任何令人信服的答案。

最好查看主要文档:setModal

modal - specifies whether dialog blocks input to other windows when shown;

另请注意

This method is obsolete and is kept for backwards compatibility only. Use setModalityType() instead.

然后检查 Dialog.ModalityType 以查看您的选项。