- Layout manager
Layout managers are software components used in
widget toolkit s which have the ability to lay out widgets by their relative positions without using distance units. It is often more natural to define component layouts in this manner than to define their position inpixel s or common distance units, so a number of popularwidget toolkit s include this ability by default. Widget toolkits that provide this function can generally be classified into two groups:
*Those where the layout behavior is coded in special graphic containers. This is the case inXUL and the.NET Framework widget toolkit (both inWindows Forms and inXAML ).
*Those where the layout behavior is coded in layout managers, that can be applied to any graphic container. This is the case in the Swing widget toolkit that is part of the Java API.Examples
XUL
In XUL, one can use elements like the [http://www.xulplanet.com/tutorials/xultu/boxes.html vbox] container to stack components on top of each other.This piece of code shows 3 buttons stacked on top of each other in a vertical box:
XAML
The [http://msdn2.microsoft.com/en-us/library/system.windows.controls.dockpanel.aspx DockPanel] container lays out children components according to their "Dock" properties.This code shows 4 text blocks on top of each other.
Java Swing
The Javadoc:SE|java/awt|FlowLayout layout manager arranges components in a directional flow, much like lines of text in a paragraph. It arranges components horizontally until no more components fit on the same line, then it places them on another line.This code shows 5 buttons alongside each other on the same line:
External links
* [http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html Layout tutorial on Sun website]
* [http://www.xulplanet.com/tutorials/xultu/ XUL tutorial on XULplanet (see paragraphs 3 and 4)]
* [http://wiki.java.net/bin/view/Javadesktop/LayoutManagerShowdown Layout Manager Showdown on java.net]
Wikimedia Foundation. 2010.