JavaFX popup hidden when stage is in fullscreen mode

隐身守侯 提交于 2019-12-06 07:55:53

Assuming you're on a Mac, this is a known issue, which is fixed in 8u40. You may need to use the ea version until the full release.

The basic history of this bug is that JavaFX implemented its own full screen implementation, in order to support OS X versions prior to 10.7 (which didn't have a native full-screen mode). That implementation uses an "exclusive mode", which prevents other windows from showing. This can get pretty bad: for example ComboBoxs won't work... The issue is fixed in 8u40 by using the native mode (since OS X versions prior to 10.7 are no longer supported anyway).

Note that if you don't programmatically set full screen mode, and allow the user to go to full screen using the Mac OS button on the window title bar, then the issue should not arise.

After repeating this problem with java version '1.8.0_40', I finally found how to fix this problem!

popupStage.initStyle(StageStyle.UTILITY);

Stage.initStyle(StageStyle) -- JavaFX 8

Giving the popup a style of StageStyle.UTILITY seems to keep the popup in front of the fullscreen window even when clicking outside of the popup.

I saw this same issue when using the new Alert class in java 1.8.0_40, and setting the style to StageStyle.UTILITY fixed that as well (Dialog.initStyle(StageStyle) -- JavaFX 8).

I don't know why this works.

Side Note:

It looks like removing the call to popupStage.initOwner(...) allows the popup to appear above the full screen application, but clicking outside of the popup causes the popup to disappear.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!