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?
A border layout lays out a container, arranging and resizing its components to fit in five regions: north, south, east, west, and center. Each region may contain no more than one component, and is identified by a corresponding constant: NORTH , SOUTH , EAST , WEST , and CENTER .
The BorderLayout is used to arrange the components in five regions: north, south, east, west, and center. Each region (area) may contain one component only. It is the default layout of a frame or window.
BorderLayout is the default layout for the window objects such as JFrame, JWindow, JDialog, JInternalFrame etc. BorderLayout arranges the components in the five regions. Four sides are referred to as north, south, east, and west. The middle part is called the center.
Something like this?
BorderLayout layout = (BorderLayout)panel.getLayout(); panel.remove(layout.getLayoutComponent(BorderLayout.CENTER));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With