Introducing JLayeredPane to an existing JFrame

馋奶兔 提交于 2019-12-24 10:59:02

问题


I've been staring at Oracle's JLayeredPane tutorials but they are laid out in a manner that is confusing to me and doesn't get at what I am trying to do.

I have an application that up to now has had no concept of layers. Everything is laid out in a single layer, inside a JFrame.

I now want to introduce a component that appears sporadically, as needed, in a certain location, overlaying existing components that stay there normally. Do I have to modify my existing application JFrame so that all its top-level contents (that is, the components that are directly added to the JFrame) are instead added to the JFrame's JLayeredPane?

Or what, exactly?

I'm looking for an easy way to adapt this gui to use layers with the minimum rework of the existing GUI.

Thanks in advance for any help here.


回答1:


You may want to instead consider drawing your overlay element on the glass pane. That way you can leave the underlying structure completely as-is.



来源:https://stackoverflow.com/questions/11512411/introducing-jlayeredpane-to-an-existing-jframe

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