JDialog Not Displaying When in Fullscreen Mode

十年热恋 提交于 2019-12-01 08:22:37

问题


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.


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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

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


来源:https://stackoverflow.com/questions/1722922/jdialog-not-displaying-when-in-fullscreen-mode

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