全屏模式下 JDialog 不显示

发布于 2024-08-10 23:00:50 字数 558 浏览 1 评论 0原文

我有一个在全屏模式下运行的应用程序并且运行良好。现在我需要添加一个简单的、未修饰的对话框,但我遇到了麻烦。如果我最大化运行应用程序,但不是全屏运行,则对话框将按预期显示和运行。当我切换回全屏时,该对话框将不会显示。

该对话框扩展了 JDialog,仅包含一个 JSlider 和几个按钮。它未经修饰且非模态。 (出于测试目的,我禁用了模态 - 每次对话框阻止输入时强制退出应用程序都很痛苦。)我使用 setFullScreenWindow() 进入全屏模式,传入主 JFrame对于该应用程序。无论我是否将该 JFrame 设置为 JDialog 的所有者,都没有什么区别。如果我在对话框上调用 toFront() 似乎也没有帮助。

该对话框似乎处于活动状态 - 特别是因为如果我将其设置为模式,它会阻止输入 - 但只是不显示或隐藏。那么,是否有任何明显的技巧可以在全屏模式下显示 JDialog?我可能会忽略或省略的东西?

如果没有明显的解决方案,我可以稍后发布一些代码。不幸的是,我现在没有时间。

I have an application that runs in fullscreen mode and has been working fine. Now I need to add a simple, undecorated dialog and I'm running into trouble. If I run the application maximized but not in fullscreen, the dialog displays and functions as expected. When I switch back to fullscreen, the dialog will not display.

The dialog extends JDialog and only contains a JSlider and a couple of buttons. It is undecorated and not modal. (I disabled modality for testing purposes -- it was a pain to force exit the app every time the dialog blocked input.) I'm entering full screen mode using setFullScreenWindow(), passing in the main JFrame for the app. It doesn't make a difference if I set that very JFrame as the owner of the JDialog or not. Nor does it seem to help if I call toFront() on the dialog.

The dialog seems to be active -- especially since it blocks input if I make it modal -- but just not showing or being hidden. So, is there any obvious trick to displaying a JDialog in fullscreen mode? Something I might be overlooking or omitting?

If there's no obvious solution, I can post some code later. Unfortunately, I don't have time right now.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

雨落星ぅ辰 2024-08-17 23:00:50

JOptionPane.showInternalXXXDialog()
方法将对话框呈现为 JInternalFrames。
也许您可以考虑使用 JIternaFrame 来模拟对话框。

JOptionPane.showInternalXXXDialog()
methods render dialogs as JInternalFrames.
Maybe you could consider using a JIternaFrame to simulate the dialog box.

你的他你的她 2024-08-17 23:00:50

事实上,正如 M1EK 在他的回答中提到的以及我在评论中提到的那样,全屏模式下的 Java 应用程序将不允许其他窗口显示在它们之上。 GraphicsDevice 的 Javadoc API 内容如下:

窗口不能与全屏窗口重叠。所有其他应用程序窗口将始终按 Z 顺序显示在全屏窗口下方。

最后,我重新配置了我的应用程序,使其稍后才进入全屏模式。这仍然在开始时给了我一个相当不错的演示,并允许我的 JDialog 按其应有的方式运行。即使在我的应用程序的“中间”,到全屏模式的过渡也快速而流畅。

And in fact, as M1EK alluded in his answer and I mentioned in a comment, Java applications in full screen mode will not allow other windows to show over them. The Javadoc API for GraphicsDevice reads:

Windows cannot overlap the full-screen window. All other application windows will always appear beneath the full-screen window in the Z-order.

In the end, I reconfigured my application so that it doesn't enter full screen mode until a bit later. This still gives me a fairly class presentation at the start and allows my JDialog to function as it should. The transition to full screen mode is quick and smooth, even in the "middle" of my app.

月光色 2024-08-17 23:00:50

您真的希望此应用程序处于全屏模式吗?我一直认为,这更像是一种游戏功能 - 更直接地访问帧缓冲区。您是否阅读过本教程:

http://java.sun。 com/docs/books/tutorial/extra/fullscreen/index.html

在我看来,这确实不是带有子窗口的 Swing 应用程序的最佳选择。

Do you really want to be in full-screen mode for this app? That's more of a gaming feature - to get more direct access to the frame-buffer, I always thought. Have you read this tutorial:

http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html

Really seems to me not to be the best choice for a Swing app with child windows.

幸福丶如此 2024-08-17 23:00:50

尝试使用这个。不是独家全面屏,但也足够接近了。

setExtendedState(JFrame.MAXIMIZED_BOTH);
setUndecorated(true);

Try to use this. Is not an exclusive full screen but it is close enough.

setExtendedState(JFrame.MAXIMIZED_BOTH);
setUndecorated(true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文