简体   繁体   English

模态对话框不总是以未装饰的框架位于顶部

[英]Modal dialog not always on top with undecorated frame

I use an undecorated JFrame with a modal dialog. 我使用带有模式对话框的未修饰的JFrame。 The problem is the modal dialog is always on top when the frame is decorated but nto laways on top when the frame is undecorated. 问题在于,当装饰框架时,模式对话框始终位于顶部,而当未装饰框架时,nto对话框始终位于顶部。 So when I click on my JFrame, the frame is displayed on top and the dialog go underneath. 因此,当我单击我的JFrame时,框架显示在顶部,而对话框则显示在下面。

I use this code. 我使用此代码。

final JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.setSize(new Dimension(500, 500));
frame.setUndecorated(true);
frame.setVisible(true);
JOptionPane.showInputDialog("OYE");
JOptionPane.showInputDialog(null, "HelloWorld");

In the above one the parent is null . 在上一个中,parent为null In your case set parent as your frame . 在您的情况下,将父项设置为frame

Example: 例:

JOptionPane.showInputDialog(frame, "HelloWorld");

See showInputDialog for more details. 有关更多详细信息,请参见showInputDialog

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM