Java Swing transparent JPanels problem

故事扮演 提交于 2019-12-05 12:47:01

Remove the line

lp.setLayout(new BorderLayout());

and replace your add() calls with

lp.add(component, layer);

You're using LayeredPane incorrectly - with LayeredPane, you (typically) don't want to set a layout. I believe (but would have to check) that the reason you're only seeing the one line is that, with BorderLayout, if you add multiple components to the same region (e.g. BorderLayout.CENTER), only the last one you add gets positioned; the others are effectively removed from the layout.

For more detail, see the Swing tutorial on Layered Panes

You are adding your panels to the same BorderLayout region.

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