views:

36

answers:

2

I was wondering if it is possible to force components in BorderLayout to wrap like they do in FlowLayout.

+1  A: 

BorderLayout, in principle, have only 5 positions: North, South, East, West and Center. If you want to micro-manage one of those positions, it is best that you put a JPanel there, and tweak its layout (e.g., set it to FlowLayout).

Little Bobby Tables
But I thought FlowLayout is the default layout manager for every JPanel, anyay I tried it and it doesn't wrap, I think because of setting the containing JFrame to BorderLayout, there is some issue with the wrapping.
gmunk
Flow layout is the default, *except of the content frame*, that is set to border layout.
Little Bobby Tables
+1  A: 

When using a FlowLayout the components will wrap automatically. The problem is that the height of the panel does not increase automaically, so you may never see the wrapped components. The Wrap Layout tries to address this issue.

camickr