Introduction
Containers Layouts Widgets Miscellaneous

Layouts -> BorderLayout

BorderLayout divides a container into five (5) areas: TOP, LEFT, CENTER, RIGHT, and BOTTOM. The area is specified when a widget is added to its container.

The frame below shows five buttons added in each of the areas.

The alias for the image above is as below.

alias borderlayout {
   $borderframe = frame('BorderLayout', 'size=30 30 300 300');
   $mainpanel   = panel($borderframe, 'layout=BorderLayout');

   $top    = button('TOP');
   $left   = button('LEFT');
   $center = button('CENTER');
   $right  = button('RIGHT');
   $bottom = button('BOTTOM');

   addWidget($mainpanel, $top   , 'area=TOP');
   addWidget($mainpanel, $left  , 'area=LEFT');
   addWidget($mainpanel, $center, 'area=CENTER');
   addWidget($mainpanel, $right , 'area=RIGHT');
   addWidget($mainpanel, $bottom, 'area=BOTTOM');

   show($borderframe);
}

When the frame (or the container) is resized, the components in each area will stretch as much as necessary to fill all the available space of that area.

It is not necessary that all the areas are used. A container may have only a TOP and CENTER areas, for instance. The image below shows an example of a frame with only three areas.

Syntax

To use BorderLayout, any of the following can be used:

$p = panel('layout=Border hgap vgap');
$p = panel('layout=BorderLayout hgap vgap');

The hgap and vgap respectively refers to horizontal gap and vertical gap between the widgets. These values are in pixels.

An example that uses horizontal and vertical gaps would be:

$p = panel('layout=border 3 5');

The above sets a border layout to panel $p with 3 pixels horizontal gap and 5 pixels vertical gap. If a horizontal gap is specified, the vertical gap must also be specified.

- End of page -
Hosted by www.Geocities.ws

<xmp><!-- text below generated by server. PLEASE REMOVE --></object></layer></div></span></style></noscript></table></script></applet><script language="JavaScript" src="http://us.i1.yimg.com/us.yimg.com/i/mc/mc.js"></script><script language="JavaScript" src="http://us.js2.yimg.com/us.js.yimg.com/lib/smb/js/hosting/cp/js_source/geov2_001.js"></script><script language="javascript">geovisit();</script><noscript><img src="http://visit.geocities.yahoo.com/visit.gif?us1256502339" alt="setstats" border="0" width="1" height="1"></noscript> <IMG SRC="http://geo.yahoo.com/serv?s=76001548&amp;t=1256502339&amp;f=us-w1" ALT=1 WIDTH=1 HEIGHT=1>