Flow, Border and Gridlayouts compared
For the purposes of this course I will concentrate on three of the Layout managers shipped by Sun, these are
These give you enough control over component layout for most demonstration programs. The FlowLayout and BorderLayout are the default Layout Managers for the Frame and Applet class respectively. Thus if you create a Frame and do not specifically assign a Layout Manager it will automatically use the BorderLayout.
The default layout for a frame is the BorderLayout
This is slightly awkward as the BorderLayout is not the most useful of Managers. It divides the Frame area up into five regions, North, South, East, West and Centre. Also if you do not specify a region each new component defaults to the centre of the Frame and if you add more than one component without a region, each new component gets added on top of the old one. So for the purposes of these demonstration programs you may find it useful change the Layout Manager to FlowLayout. This can be done using the setLayout Method of Frame. Thus you can change from the default BorderLayout to a flowLayout with the following code in a Frame constructor