gt:             int sectionX = parent.getInsets().left;
context: // $Id: LabelledLayout.java 41 2010-04-03 20:04:12Z marcusvnac $
  // Copyright (c) 2008-2009 The Regents of the University of California. All
  // Rights Reserved. Permission to use, copy, modify, and distribute this
  // software and its documentation without fee, and without a written
  // agreement is hereby granted, provided that the above copyright notice
  // and this paragraph appear in all copies. This software program and
  // documentation are copyrighted by The Regents of the University of
  // California. The software program and documentation are supplied "AS
  // IS", without any accompanying services from The Regents. The Regents
  // does not warrant that the operation of the program will be
  // uninterrupted or error-free. The end-user understands that the program
  // was developed for research purposes and is advised not to rely
  // exclusively on the program for any reason. IN NO EVENT SHALL THE
  // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
  // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
  // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
  // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
  // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
  // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
  // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
  // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
  // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  
  package org.argouml.uml.ui;
  
  import java.awt.Component;
  import java.awt.Container;
  import java.awt.Dimension;
  import java.awt.Insets;
  import java.awt.LayoutManager;
  import java.util.ArrayList;
  import javax.swing.JComboBox;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.UIManager;
  
  /**
   * This layout manager lines up components in 2 columns. All JLabels
   * are the first column and any component the JLabel is registered
   * with is in a second column next to the label. <p>
   *
   * Components are sized automatically to fill available space in the container
   * when it is resized. <p>
   * 
   * All JLabel widths will be the largest of the JLabel preferred widths (unless
   * the container is too narrow). <p>
   * 
   * The components will take up any left over width unless they are
   * restricted themselves by a maximum width. <p>
   * 
   * The height of each component is either fixed or will resize to use up any
   * available space in the container. Whether a components height is resizable
   * is determined by checking whether the preferred height of that component is
   * greater then its minimum height. This is the case for components such as
   * JList which would require to expand to show the maximum number or items. <p>
   * 
   * If a component is not to have its height resized then its preferred
   * height and minimum height should be the same. This is the case for
   * components such as JTextField and JComboBox* which should always stay the
   * same height. <p>
   * 
   * [There is known bug in JRE5 where the prefered height and minimum height of
   * a JComboBox can differ. LabelledLayout has coded a workaround for this bug.
   * See - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6255154 ] <p>
   * 
   * LabelledLayout can show multiple panels of label/component
   * pairs. The seperation of these panels is indicated by adding a
   * Seperator component to the container. Labelled layout starts
   * a new panel when detecting this Seperator. <p>
   * 
   * When there are multiple panels, each panel is given equal width.
   * The width restriction of JLabels and components described above are then
   * dependent on panel width rather than container width.
   *
   * @author Bob Tarling
   */
  class LabelledLayout implements LayoutManager, java.io.Serializable {
  
      private static final long serialVersionUID = -5596655602155151443L;
  
      /**
       * This is the horizontal gap (in pixels) which specifies the space
       * between sections.  They can be changed at any time.
       * This should be a non negative integer.
       *
       * @serial
       * @see #getHgap()
       * @see #setHgap(int)
       */
      private int hgap;
      
      /**
       * This is the vertical gap (in pixels) which specifies the space
       * between rows.  They can be changed at any time.
       * This should be a non negative integer.
       *
       * @serial
       * @see #getVgap()
       * @see #setVgap(int)
       */
      private int vgap;
  
      private boolean ignoreSplitters;
  
      /**
       * Construct a new LabelledLayout.
       */
      public LabelledLayout() {
          ignoreSplitters = false;
          hgap = 0;
          vgap = 0;
      }
  
      /**
       * Construct a new LabelledLayout.
       */
      public LabelledLayout(boolean ignoreSplitters) {
          this.ignoreSplitters = ignoreSplitters;
          this.hgap = 0;
          this.vgap = 0;
      }
  
      /**
       * Construct a new horizontal LabelledLayout with the specified
       * cell spacing.
       * @param hgap The horizontal gap between components
       * @param vgap The vertical gap between components
       */
      public LabelledLayout(int hgap, int vgap) {
          this.ignoreSplitters = false;
          this.hgap = hgap;
          this.vgap = vgap;
      }
  
      /** 
       * Adds the specified component with the specified name to the
       * layout. This is included to satisfy the LayoutManager interface
       * but is not actually used in this layout implementation.
       *
       * @param name the name of the component
       * @param comp the component to be added
       */
      public void addLayoutComponent(String name, Component comp) {
      }
  
      /** 
       * Removes the specified component from
       * the layout. This is included to satisfy the LayoutManager
       * interface but is not actually used in this layout
       * implementation.
       *
       * @param comp the component
       */
      public void removeLayoutComponent(Component comp) {
      }
  
      /**
       * Determines the preferred size of the container argument using
       * this labelled layout.  The preferred size is that all child
       * components are in one section at their own preferred size with
       * gaps and border indents.
       */
      public Dimension preferredLayoutSize(Container parent) {
          synchronized (parent.getTreeLock()) {
              final Insets insets = parent.getInsets();
              int preferredWidth = 0;
              int preferredHeight = 0;
              int widestLabel = 0;
  
              final int componentCount = parent.getComponentCount();
              for (int i = 0; i < componentCount; ++i) {
                  Component childComp = parent.getComponent(i);
                  if (childComp.isVisible()
                          && !(childComp instanceof Seperator)) {
                      int childHeight = getPreferredHeight(childComp);
                      if (childComp instanceof JLabel) {
                          final JLabel jlabel = (JLabel) childComp;
                          widestLabel = 
                              Math.max(widestLabel, getPreferredWidth(jlabel));
                          childComp = jlabel.getLabelFor();
                          final int childWidth = getPreferredWidth(childComp);
                          preferredWidth = 
                              Math.max(preferredWidth, childWidth);
  
                          childHeight =
                              Math.min(childHeight, getPreferredHeight(jlabel));
                      }
                      preferredHeight += childHeight + this.vgap;
                  }
              }
              preferredWidth += insets.left + widestLabel + insets.right;
              preferredHeight += insets.top + insets.bottom;
              return new Dimension(
                      insets.left + widestLabel + preferredWidth + insets.right,
                      preferredHeight);
          }
      }
      
      /** 
       * Required by LayoutManager.
       * 
       * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
       */
      public Dimension minimumLayoutSize(Container parent) {
          synchronized (parent.getTreeLock()) {
              final Insets insets = parent.getInsets();
              int minimumHeight = insets.top + insets.bottom;
  
              final int componentCount = parent.getComponentCount();
              for (int i = 0; i < componentCount; ++i) {
                  Component childComp = parent.getComponent(i);
                  if (childComp instanceof JLabel) {
                      final JLabel jlabel = (JLabel) childComp;
                      childComp = jlabel.getLabelFor();
                      
                      final int childHeight = Math.max(
                              getMinimumHeight(childComp),
                              getMinimumHeight(jlabel));
                      minimumHeight += childHeight + this.vgap;
                  }
              }
              return new Dimension(0, minimumHeight);
          }
      }
  
      /**
       * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
       */
      public void layoutContainer(Container parent) {
          synchronized (parent.getTreeLock()) {
  