예제 #1
0
  /**
   * The method is an implementation of appropriate layout manager method. The method performs
   * layouting of the child layoutable components for the specified target component.
   *
   * @param target the specified layoutable container.
   */
  public void layout(LayoutContainer target) {
    Insets targetInsets = getInsets();

    int y = 0, x = 0, w = 0, h = 0;
    if (label != null && label.isVisible()) {
      Dimension ps = label.getPreferredSize();
      y =
          (getTitleAlignment() == LwToolkit.BOTTOM)
              ? (height - targetInsets.bottom - ps.height)
              : targetInsets.top;
      x =
          (xAlignment == LwToolkit.LEFT)
              ? targetInsets.left + INDENT
              : ((xAlignment == LwToolkit.RIGHT)
                  ? width - targetInsets.right - ps.width - INDENT
                  : (width - ps.width) / 2);
      w = ps.width;
      h = ps.height;
      label.setSize(w, h);
      label.setLocation(x, y);
    }

    if (center != null && center.isVisible()) {
      center.setLocation(
          targetInsets.left + hGap,
          (getTitleAlignment() == LwToolkit.BOTTOM ? targetInsets.top : targetInsets.top + h)
              + vGap);
      center.setSize(
          width - targetInsets.right - targetInsets.left - 2 * hGap,
          height - targetInsets.top - targetInsets.bottom - h - 2 * vGap);
    }
  }
예제 #2
0
  /**
   * The method computes a preferred size for the specified target component.
   *
   * @param target the specified layoutable container.
   */
  public Dimension calcPreferredSize(LayoutContainer target) {
    Dimension ps =
        center != null && center.isVisible() ? center.getPreferredSize() : new Dimension();

    if (label != null && label.isVisible()) {
      Dimension lps = label.getPreferredSize();
      lps.width += INDENT;
      ps.height += lps.height;
      ps.width = Math.max(ps.width, lps.width);
    }
    ps.width += (hGap * 2);
    ps.height += (vGap * 2);
    return ps;
  }