Keep JFrame on top of others

你说的曾经没有我的故事 提交于 2020-01-05 13:27:30

问题


I am in a situation where I create a frame FrameB from my main frame FrameA. When the user is working on FrameB I would like it to be on top of FrameA even when the user accidentally clicks on FrameA.


回答1:


Do you have to use a JFrame?

If you use a JDialog instead of a JFrame and assign FrameA as the owner of the dialog through the constructor it will always remain on top of the frame. (Example: How to set the JFrame as a parent to the JDialog)

Otherwise you can use setAlwaysOnTop() from the window class, but this can be dependent on the operating system/window manager.




回答2:


You could consider making FrameB a JDialog instead of JFrame, and set it modal.



来源:https://stackoverflow.com/questions/1620350/keep-jframe-on-top-of-others

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