在全屏模式下,JDialog不显示 [英] JDialog Not Displaying When in Fullscreen Mode

查看:289
本文介绍了在全屏模式下,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.

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

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.

该对话框似乎处于活动状态 - 特别是因为它阻止输入,如果我使它模态 - 但只是不显示或隐藏。那么,在全屏模式下显示JDialog有什么明显的诀窍吗?我可能忽略或省略的东西?

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.

推荐答案

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

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不能与全屏窗口重叠。所有其他应用程序窗口将始终显示在Z顺序的全屏窗口下方。

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

最后,我重新配置了我的应用程序,以便它稍后不会进入全屏模式。这仍然在开始时给我一个相当类的演示,并允许我的JDialog按预期运行。即使在我的应用程序的中间,过渡到全屏模式也是快速而流畅的。

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.

这篇关于在全屏模式下,JDialog不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆