<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>JGoodies Forms :: Reference :: Alignments</title> <link rel="stylesheet" type="text/css" href="../style.css" > <meta name="description" content="The JGoodies Forms helps you layout and implement elegant Panel quickly and consistently."> <meta name="author" content="Karsten Lentzsch"> <meta name="keywords" content="JGoodies Forms Java Layout Swing UI Design Usability Lentzsch Kiel"> <meta name="robots" content="index, follow"> <meta name="date" content="2003-07-31"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0" bottommargin="0" > <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td colspan="3" bgcolor="DDDCDC"><a href="../../README.html"><img src="../images/banner.gif" width="436" height="46" alt=":: JGOODIES :: Forms" border="0"></a></td> </tr> <tr> <td colspan="3" height="1" bgcolor="C9C8C8"></td> </tr> <tr> <td width="160" height="500" valign="top" bgcolor="F4f3f3" class="nav" nowrap="nowrap"> <div style="margin-left: 17px; margin-top: 17px; margin-right: 10px; ; margin-bottom: 17px; line-height: 18px;"> <!-- ************ Anfang der Seitennavigation **************************** --> <b>General</b> <br>:: <a class="nav" href="../../README.html">Readme</a> <br>:: <a class="nav" href="../../RELEASE-NOTES.txt">Release Notes</a> <br>:: <a class="nav" href="../../LICENSE.txt">License</a> <br>:: <a class="nav" href="../whitepaper.pdf">Whitepaper</a> <br>:: <a class="nav" href="../visualbuilders.html">Visual Builders</a> <br>:: <a class="nav" href="../references.html">References</a> <br>:: <a class="nav" href="../tips.html">Tips & Tricks</a> <br>:: <a class="nav" href="https://forms.dev.java.net/faq.html">FAQ</a> <p> <b>Tutorial</b> <br>:: <a class="nav" href="../tutorial/introduction.html">Introduction</a> <br>:: <a class="nav" href="../tutorial/quickstart.html">Quick Start</a> <br>:: <a class="nav" href="../tutorial/basics.html">Basics</a> <br>:: <a class="nav" href="../tutorial/building.html">Building</a> <br>:: <a class="nav" href="../tutorial/factories.html">Factories</a> <p> <b>Reference</b> <br>:: <a class="nav" href="alignments.html"><b>Alignments</b></a> <br>:: <a class="nav" href="constantsizes.html">Constant Sizes</a> <br>:: <a class="nav" href="componentsizes.html">Component Sizes</a> <br>:: <a class="nav" href="boundedsizes.html">Bounded Sizes</a> <br>:: <a class="nav" href="colsandrows.html">Cols & Rows</a> <br>:: <a class="nav" href="cells.html">Cell Constraints</a> <br>:: <a class="nav" href="groups.html">Groups</a> <br>:: <a class="nav" href="variables.html">Layout Variables</a> <p> <a class="nav" href="../api/index.html"><b>API Docs</b></a> <p> <b>Web Pages</b> <br>:: <a class="nav" href="http://forms.dev.java.net/">Project Home</a> <br>:: <a class="nav" href="http://www.jgoodies.com/downloads/libraries.html">Downloads</a> <br>:: <a class="nav" href="http://forms.dev.java.net/servlets/ProjectNewsList">Announcements</a> <br>:: <a class="nav" href="http://forms.dev.java.net/servlets/ProjectMailingListList">Mailing Lists</a> <br>:: <a class="nav" href="http://forms.dev.java.net/servlets/ProjectIssues">Issue Tracker</a> <br>:: <a class="nav" href="http://www.jgoodies.com/freeware/">More Examples</a> <!-- *********** Ende der Seitennavigation ******************************* --> </div> </td> <td width="1" bgcolor="E7E5E5"><img src="/images/banner.gif" width="1" height="1" alt=""></td> <td width="90%" valign="top" > <div style="margin-left: 20px; margin-top: 17px; margin-bottom: 17px"> <!-- ************ Anfang des Inhalts ***************************************** --> <table width="530" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <h1>:: Reference :: Alignments ::</h1> Column alignments are: <i>left, center, right, fill</i>.<br> And row alignments are: <i>top, center, bottom, fill</i>. <p>The <i>fill</i> alignment expands a component to span its display area, so that the component's left-hand side is left-aligned, and the right-hand side is right-aligned. The same applies to top/bottom for rows. <h2>Applying Defaults</h2> FormLayout aims to minimize the effort to specificy alignments. Therefore it 1) tries to reuse alignments, 2) provide good defaults for form oriented layouts. <p>1) The column and row alignments are applied to all components that are located in a single cell of that column/row. A component can override its column/row alignment by setting an individual alignment via a <i>CellConstraints</i> object. <p>2) By default, the column alignment is set to <i>fill</i>. The implicit alignment for rows is <i>center</i>. And so, if you don't specify column and row alignments, your components will be horizontally filled and vertically centered. This is a good default for most text fields, combo boxes, buttons and it works fine with labels too. <h2>Alignment Constants</h2> The classes <tt>ColumnSpec</tt>, <tt>RowSpec</tt> provide constant values for the alignment values mentioned above. <h2>String Representations</h2> I recommend to specify column and row alignments in the FormLayout constructor using string representations. These strings will be accepted by the <tt>FormLayout</tt>, <tt>ColumnSpec</tt>, <tt>RowSpec</tt> and <tt>CellConstraints</tt> classes and by many builder methods. <pre> columnAlignment ::= LEFT | CENTER | RIGHT | FILL | L | C | R | F rowAlignment ::= TOP | CENTER | BOTTOM | FILL | T | C | B | F </pre> <h2>Examples</h2><pre> ColumnSpec.LEFT; ColumnSpec.FILL; new ColumnSpec("left"); new ColumnSpec("f"); RowSpec.BOTTOM; RowSpec.CENTER; new RowSpec("bottom"); new RowSpec("c"); new FormLayout("left:pref, 4dlu, fill:pref", " top:pref, 3dlu, center:pref"); new CellConstraints(2, 3, ColumnSpec.LEFT, RowSpec.TOP); new CellConstraints(2, 3, "left, top"); new CellConstraints(2, 3, "l, t"); CellConstraints cc = new CellConstraints(); builder.add(component, cc.xy(2, 3, "left, top"); </pre> </td> </tr> </table> <!-- ************ Ende des Inhalts ************************************** --> </div> </td> </tr> <tr> <td nowrap="nowrap" bgcolor="F4f3f3"> <div style="font-size: 10px; margin-left: 17px; margin-top: 20px; margin-right: 10px; margin-bottom: 4px;"> (c) 2008 JGoodies </div> </td> <td width="1" bgcolor="E7E5E5"></td> <td> </td> </tr> <tr> <td colspan="2" height="1" bgcolor="E7E5E5"></td> <td></td> </tr> </table> </body> </html>