问题
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