Components in the Layout | Table of Possible Layout Managers |
What Layout Managers Do | Gotchas |
Null Layouts | Learning More |
Nested Containers | Links |
These methods often return 0,0 as the size. The reason is, they rely on the underlying GUI (Graphic User Interface) to compute the size and if there in no peer object yet, there is no hook to ask the native GUI. See addNotify.
You should almost never use null layouts and setLocation. This is a last ditch emergency method when all layout managers have failed to give you decent positioning and it would be impossible to write a layout manager with enough common sense.
When you do use manual layout you must do several things:
Possible Layout Managers | |
---|---|
Layout | Purpose |
AbsoluteLayout | Netbeans absolute position layout. |
BorderLayout |
Place components on a simple north, south, east, west, center grid.
Oracle’s Javadoc on BorderLayout class : available:
|
BoxLayout |
Place components in a single row or column. Designed to work with glue and
strut objects of the Box class to control where
extra space goes. Aligns based on the
JComponent.getAlignmentX
and JComponent.getAlignmentY
properties of the JComponents in the Container. To control alignment use
JComponent.setAlignmentX
( 0.0F ) for left aligned, setAlignmentX( .5F ) for
centered and setAlignmentX( 1.0F ) for right aligned. Only available in Swing.
Oracle’s Javadoc on BoxLayout class : available:
|
CardLayout |
Allows you to flip through several panels, where only one is visible at a
time. Oracle’s Javadoc on CardLayout class : available:
|
DesignGridLayout | Uses Patrizia Nanni’s canonical grids. |
EasyLayout | Stripped down GridBagLayout. Has just weights and grid numbers. |
ExplicitLayout | Allows non-rectangular layouts. By Zooki Technology. |
FillLayout | SWT (Standard Widget Toolkit). lays out equal-sized widgets in a single row or column. |
FlowLayout |
Simple flow left to right, top to bottom stream of components. This is a very
rough and ready, quick and dirty layout for prototypes. If you want fine
control and professional looks, try another.
Oracle’s Javadoc on FlowLayout class : available:
|
FormLayout | Karsten Lentzsch’s free, open source LayoutManager. Karsten is the Leonardo da Vinci of layout designers. His layouts get every last picky detail correct, including working with larger-than-expected fonts. Even if you don’t use his layouts, read what he has to say about GUI design. version 1.2 is coming soon which has layout variables for meta design constants. Last revised/verified: 2008-04-04 For example, 85dlu for all label column widths, 100dlu for the minimum table height, etc. See scalable layouts for a discussion of the problem of scaling layouts. |
GridBagLayout | Oracle’s mother of all layout managers. It is complicated and powerful. To cover it requires a separate entry. Place components on a rough n x m grid. Some components may take up multiple cells. Fine tuning of whitespace around each component and alignment of each component within its grid cell. Requires a lot of tweaking to make it look right. The cells are not necessarily the same size. They adjust to fit the components, based on various hints you give. |
GridLayout |
Layout components in a regular n × m grid. All cells are the same width
and height. Oracle’s Javadoc on GridLayout class : available:
|
GridLayout SWT | SWT. lays out widgets in a grid FormLayout |
GroupLayout | Part of Netbeans/Matisse. It is not bundled with the JDK (Java Development Kit). It backs up the visual layout abilities of Matisse. |
HIGLayout | Similar to TableLayout, by Daniel Michelik |
JTabbedPane | JTabbedPane is a JComponent, not a LayoutManager, but it behaves much like a CardLayout with tabs. |
JSplitPane | JSplitPane is a JComponent, not a Layout, but it behaves much like one with two panels and a moveable boundary between them. |
LabeledGridBagLayout | Like a GridBagLayout that automatically labels fields with their corresponding field names. Requires use of smart components that know their field labels. Part of the com.mindprod.business package. |
Matisse: aka Gui Builder | A new NetBeans scheme for building layouts interactively with a backing set of layout managers. It is still in alpha test. |
MigLayout | Free. Intended to be a universal layout manager for all possible applications. This is RedGrittyBrick’s favourite layout manager. Has tools for writing resolution-independent code. |
Packer | A front end to the GridBagLayout using a fluent interface to cut down the number of positional parameters. Not to be confused with PackerLayout. |
PackerLayout | A Java version of the Tcl/Tk layout manager. Some of the GridBag pad/expand abilities. |
RowLayout | SWT. lays out widgets in a row or rows, with fill, wrap and spacing options. |
fuin.org ScalableLayout | Zoom the Swing UI (User Interface) (like CTRL+/CTRL- in Firefox for web pages) |
SpringLayout | Uses
a model of structs and springs to control the sizes and positions of boxes.
Only available in Swing.
Oracle’s Javadoc on SpringLayout class : available:
|
StarLayout | Arranges objects in star shaped patterns. You place components by giving the angle and radius from the centre of the container. |
TableLayout | A simplified GridBagLayout. You explicitly control the relative sizes of each row and column. By Daniel Barbalace and the ClearThought TableLayout Project. |
XYLayout | Borland absolute position layout. |
NetBeans and JBuilder have GUI layout builders. Radical is a stand-alone GUI Builder.
This page is posted |
http://mindprod.com/jgloss/layout.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\layout.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.133.153.134] |
| |
Feedback |
You are visitor number | |