Showing JDialog in taskbar not working

前端 未结 1 855
被撕碎了的回忆
被撕碎了的回忆 2021-01-18 14:02

I\'m using the below code to showing JDialog on taskbar and is perfectly working in JDK 1.6.

public class test8 {   
    public static void main(String[] arg         


        
1条回答
  •  北荒
    北荒 (楼主)
    2021-01-18 14:59

    The problem is that certain constructors of JDialog create a dummy frame owner if the owner is null for historical reasons. But a Dialog must not have an owner to be visible like a top-level window. I.e.

    JDialog d=new JDialog((Window)null);
    d.setModalityType(ModalityType.TOOLKIT_MODAL);
    d.setVisible(true);
    

    will work.

    0 讨论(0)
提交回复
热议问题