Removing the CENTER element from a JPanel using BorderLayout

做~自己de王妃 提交于 2019-12-17 16:14:48

问题


Is there any way of removing the Component added to the CENTER of a JPanel with a BorderLayout, without having to reference the Component itself?


回答1:


Something like this?

BorderLayout layout = (BorderLayout)panel.getLayout();
panel.remove(layout.getLayoutComponent(BorderLayout.CENTER));


来源:https://stackoverflow.com/questions/759321/removing-the-center-element-from-a-jpanel-using-borderlayout

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