<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>JGoodies Forms :: Reference :: Constant Sizes</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">Alignments</a> <br>:: <a class="nav" href="constantsizes.html"><b>Constant Sizes</b></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 :: Constant Sizes ::</h1> Constant sizes are used to set the size of gaps and other fixed layout elements. They can also be used in bounded sizes as lower or upper bound. <h2>Units</h2> Constant sizes are specified by a value plus unit that is one of: <i>Pixel, Points, Inches, Millimeter, Centimeter</i> and <i>Dialog Units</i>. In string representations the units are abbreviated as: <i>px, pt, in, mm, cm</i> and <i>dlu</i>. <h2>Constant Non-Pixel Sizes</h2> Constant sizes are constant for a given dialog font, font size and screen resolution. Pixel sizes map to a fixed dimension in pixels - even if these parameters change. This is undesired in screen design, especially in multi-platform environments. Therefore you should favor non-pixel sizes over pixel sizes. <p> If you move an application from Windows to Mac or Linux, you want to retain the overall appearance and layout propertions. And if you just change your Windows desktop font settings, you want all layout elements grow appropriately: labels, fields, buttons, but also: gaps, borders, minimum sizes and dialog dimensions. <p> Layout managers have been designed to address this issues. Nevertheless, most of them fail to retain proportions if you specify dimensions in pixel, which is often the case for gaps, borders, dialog sizes, and custom minimum and preferred sizes. <p> For example, a well designed OK button shall have a minimum width; 75px is appropriate for an 8pt Tahoma font on Windows with 96dpi. But on 120dpi and 10pt Arial, 75 pixels are perceived as quite narrow. <i>Dialog Units</i> allow to specify such a size in a way that it grows and shrinks with the environment. For example, the MS layout style guide suggests a command button minimum width of 50dlu, which maps to 75px in the first context and to 100px in the second. <p><i>Points, Inches, Millimeters</i> and <i>Centimeters</i> are intended for sizes that shall grow with the screen resolution but that are independent of the font and font size. <h2>Unit Conversion</h2> Class <tt>Sizes</tt> provides methods to convert non-pixel sizes to pixels. The actual mapping is performed by a customizable <i>Unit converter</i>. <h2>Prototype Sizes</h2> You can describe a column width or row height by providing a string prototype, for example <tt>new FormLayout("right:pref, 3dlu, '+49-89-32168'")</tt>. Prototype sizes scale better than <i>Dialog Units</i> if the content consists only of special characters, for example digits. <h2>Logical Constant Sizes</h2> Logical sizes can be used to specify a size that changes with the current platform or style guide. For example, if you want to specify a button's minimum width, you may want to use <i>50dlu</i> on Windows and <i>68px</i> on a Mac. Or you define the gap between two related text field rows as <i>3dlu</i> on Windows and <i>4px</i> on a Mac. <p> The Forms layout system supports logical sizes in builder classes, via the <i>Layout Style</i> and the <tt>FormFactory</tt> constants. Since version 1.2 you can use logical sizes in encoded column and row specifications too, by means of layout variables. For example <tt>new FormLayout("right:pref, $lcgap, pref")</tt> uses the short name of the variable <tt>$label-component-gap</tt> that describes the platform-specific gap between a label and its associated component. <p> The <tt>ButtonBarFactory</tt>, <tt>ButtonBarBuilder</tt> and <tt>ButtonStackBuilder</tt> use logical sizes and in turn style guide-specific logical sizes for frequently used gaps and minimum widths and heights. For example the <tt>ButtonBarBuilder</tt> uses logical sizes to honor style guide settings for button minimum width, and gaps between related and unrelated components. <p> If you develop a custom builder class, you can refer to the logical sizes using the current <i>Layout Style</i> or the <tt>FormFactory</tt> constants. <h2>String Representations</h2> I recommend to specify column and row sizes 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>Borders</tt> classes. <pre> constantSize ::= <integer>integerUnit | <double>doubleUnit integerUnit ::= PX | PT | DLU doubleUnit ::= IN | MM | CM </pre> <h2>Examples</h2> <pre> new ColumnSpec("50dlu"); new ColumnSpec("75px"); new ColumnSpec("'xxx-MMM-000-xxx'"); new RowSpec("2in"); new RowSpec("100px"); new FormLayout("100dlu, 4dlu, 200dlu", " 14dlu, 3dlu, 14dlu"); </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>