advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement



Title: Professional Java Programming
ISBN: 186100382x
US Price: $ 59.99
Canadian Price:
C$ 89.95
UK Price: £ 45.99
© Wrox Press Limited, US and UK.

Reviews : Java Books :
Professional Java Programming : Using Layout Managers

GridBagLayout

The GridBagLayout layout manager is by far the most flexible layout manager that's included with Java, but it does not enjoy widespread popularity among Java programmers due to its complexity and its sometimes non-intuitive behavior.

However, GridBagLayout is often the only layout manager flexible enough to arrange components in a particular manner, and is used frequently in spite of the difficulty involved.

As its name implies, GridBagLayout bears some similarity to GridLayout, but only at a very superficial level. Both divide the container's available display area into a grid of cells, but beyond that, GridBagLayout and GridLayout don't have much in common. Some of the important differences between them include the following:

  • When using a GridLayout, a component's position within the grid is determined by the order in which it is added to the container relative to other components. With a GridBagLayout , you can explicitly define the component's location within the grid.
  • Each component in a GridLayout occupies exactly one cell in the grid, but components managed by a GridBagLayout can span multiple rows and/or columns within the grid.
  • GridLayout assigns each row the same height and each column the same width, which causes every cell in the grid to have exactly the same dimensions. In contrast, GridBagLayout allows each row to have a separate height and every column its own width, so every cell in the grid can theoretically have a unique size.
  • GridLayout does not support any constraints, while GridBagLayout allows you to specify a different set of constraint values for each component, and those constraints allow you to customize the component's size and position within the grid.

If you're not already familiar with it, you may be wondering why  GridBagLayout is considered so difficult to use by many Java programmers. Some of the possible reasons are:

  • The number of constraints and their interactions
    GridBagConstraints encapsulates eleven different constraint values, and each child component is assigned its own instance of GridBagConstraints. Although no single constraint is particularly difficult to understand, the way in which the constraints interact with one another and with the constraints of other components is somewhat complex.

  • Row height and column widths
    GridBagLayout 's ability to provide a separate height for each row and width for each column is one of its primary advantages, but that capability also adds a great deal of complexity to its use. In some cases, especially with complex layouts containing many components, it can be difficult to predict what a component's size or position will be, and it's easy to make mistakes that produce results different from what you expected.

  • Component location
    When you see a component inside a GridLayout, it's usually easy to identify which cell the component occupies without examining the source code. That's because all cells (and components) are the same size, and the cells are aligned with one another. In the case of a GridBagLayout, identifying which cell or cells a component occupies can be difficult, since cell widths and heights can vary and since a component can span multiple cells.

  • Component size
    Most other layout managers have simple rules that determine the size that a component is set to, but GridBagLayout provides much greater flexibility in this area, as well as more complexity.

    How to Add Java Applets to Your Site

    New on the Java Boutique:

    New Review:

    Time Management Made Easy with the Quartz Enterprise Job Scheduler
    Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

    New Applet:

    Reverse Complement
    Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

    Elsewhere on internet.com:

    WebDeveloper Java
    Lots of Java information on webdeveloper.com

    WDVL Java
    Thorough Java resource at the Web Developer's Virtual Library.

    ScriptSearch Java
    Hundreds of free Java code files to download.

    jGuru: Your View of the Java Universe
    Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs