使用 BorderLayout 从 JPanel 中删除 CENTER 元素 [英] Removing the CENTER element from a JPanel using BorderLayout
本文介绍了使用 BorderLayout 从 JPanel 中删除 CENTER 元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何方法可以使用 BorderLayout
删除添加到 JPanel
的 CENTER
的 Component
,无需引用 Component
本身?
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?
推荐答案
类似的事情?
BorderLayout layout = (BorderLayout)panel.getLayout();
panel.remove(layout.getLayoutComponent(BorderLayout.CENTER));
这篇关于使用 BorderLayout 从 JPanel 中删除 CENTER 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文