magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 1999 > 06 > Java@Work

Custom Layout Wizardry

By Al Williams

Sun's vision for Java has always been: "Write once, run anywhere." In practice, this may be somewhat optimistic. Still, Java is your best bet for running programs on multiple platforms -- that's why it's a success on the Web where there are dozens of different types of machines.

This machine independence poses some definite problems, however. If you develop on a Windows machine, it's difficult to tell how your program will look on a UNIX system, for example. Even on the same platform, variations in display hardware can affect your program's appearance. To combat this, Java programs use a layout manager that controls your program's appearance at run time.

Every AWT container (including an applet) has a layout manager -- the default is FlowLayout. When you add components (like buttons or list boxes) to the container, you can specify where you want each component to appear using arguments that vary between different layout managers. For example, the FlowLayout manager simply places the components side by side in the order you add them, starting a new row when it runs out of room. However, the BorderLayout manager lets you specify NORTH, SOUTH, EAST, WEST, or CENTER for each component. Other layout managers, like GridLayout and GridBagLayout, provide even more control over the placement of individual components (see last month's column, "In Search of... Visaj," for more information).

With the standard layout managers, you can usually create any visual arrangement you want.




  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2