Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java BorderLayout stretch east

Is it possible to make the east (or west) side of a BorderLayout to spread over the entire panel (include north/south)?

enter image description here

like image 222
Reinard Avatar asked Apr 12 '12 18:04

Reinard


2 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);
like image 123
Stefan Avatar answered Oct 03 '22 23:10

Stefan


not possible with single JPanel layed by BorderLayout

1) by using two JPanels, where NORTH, WEST, CENTER and SOUTH areas could be placed to the 1st JPanel (frame.add(1stPanel, BorderLayout.CENTER)) and plain 2nd JPanel to the frame.add(2ndPanel, BorderLayout.EAST),

2) you can use BoxLayout for area in the EAST from Container

3) little bit complicated could be use GridBagLayout or MigLayout (in this case)

like image 33
mKorbel Avatar answered Oct 03 '22 23:10

mKorbel