Java BorderLayout extends east

Can the east (or west) side of the BorderLayout be made to spread throughout the panel (including north / south)?

enter image description here

+5
source share
3 answers

Just remove West and East from this panel and create a new β€œparent” panel:

JPanel newPanel = new JPanel();
newPanel.setLayout(new BorderLayout());

newPanel.add(westernPanel, BorderLayout.WEST);
newPanel.add(yourOldPanel, BorderLayout.CENTER);
newPanel.add(eastenPanel, BorderLayout.EAST);
+7
source

impossible with single JPanelinstalledBorderLayout

1) using two JPanels, where NORTH, WEST, CENTERand SOUTHregions may be placed in 1st JPanel( frame.add(1stPanel, BorderLayout.CENTER)) and plain 2nd JPanelin frame.add(2ndPanel, BorderLayout.EAST),

2) you can use BoxLayoutfor area in EASTfrom Container

3) GridBagLayout MigLayout ( )

+2

Not directly, but you can have a border layout without an β€œeast” embedded in a layout that has your current East in the correct position ... Do you make sense?

TL DR: Nope.

+1
source

All Articles