java.awt.FlowLayout.layoutContainer()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中java.awt.FlowLayout.layoutContainer()方法的一些代码示例,展示了FlowLayout.layoutContainer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FlowLayout.layoutContainer()方法的具体详情如下:
包路径:java.awt.FlowLayout
类名称:FlowLayout
方法名:layoutContainer

FlowLayout.layoutContainer介绍

[英]Lays out the container. This method lets each component take its preferred size by reshaping the components in the target container in order to satisfy the alignment of this FlowLayout object.
[中]布置容器。此方法允许每个组件通过重塑目标容器中的组件来获得其首选大小,以满足此FlowLayout对象的对齐。

代码示例

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-mobility-svgcore

public void layoutContainer(Container parent) {
    super.layoutContainer( parent );
    Point point = myErrorComponent.getLocation();
    myErrorComponent.setLocation( point.x ,
        (int)(parent.getHeight() - 
            myErrorComponent.getPreferredSize().getHeight()) / 2);
  }
}

代码示例来源:origin: khuxtable/seaglass

public void layoutContainer(Container target) {
    // First shrink buttons to fit
    Component[] comps = target.getComponents();
    int n = comps.length;
    if (n > 0) {
      // Start with the largest preferred width
      int prefWidth = 0;
      for (Component c : comps) {
        c.setPreferredSize(null);
        Dimension prefSize = c.getPreferredSize();
        if (prefSize.width > prefWidth) {
          prefWidth = prefSize.width;
        }
      }
      // Shrink equally to fit if needed
      Insets insets = target.getInsets();
      int tw = target.getWidth() - insets.left - insets.right;
      int w = Math.min(prefWidth, Math.max(10, tw / n));
      for (Component c : comps) {
        Dimension prefSize = c.getPreferredSize();
        c.setPreferredSize(new Dimension(w, prefSize.height));
      }
    }
    super.layoutContainer(target);
  }
});

代码示例来源:origin: org.gephi/ui-components

/**
 *  Layout the components in the Container using the layout logic of the
 *  parent FlowLayout class.
 *
 *    @param target the Container using this WrapLayout
 */
@Override
public void layoutContainer(Container target) {
  Dimension size = preferredLayoutSize(target);
  //  When a frame is minimized or maximized the preferred size of the
  //  Container is assumed not to change. Therefore we need to force a
  //  validate() to make sure that space, if available, is allocated to
  //  the panel using a WrapLayout.
  if (size.equals(preferredLayoutSize)) {
    super.layoutContainer(target);
  } else {
    preferredLayoutSize = size;
    Container top = target;
    while (top.getParent() != null) {
      top = top.getParent();
    }
    top.validate();
  }
}

代码示例来源:origin: nroduit/Weasis

/**
 * Layout the components in the Container using the layout logic of the parent FlowLayout class.
 *
 * @param target
 *            the Container using this WrapLayout
 */
@Override
public void layoutContainer(Container target) {
  Dimension size = preferredLayoutSize(target);
  // When a frame is minimized or maximized the preferred size of the
  // Container is assumed not to change. Therefore we need to force a
  // validate() to make sure that space, if available, is allocated to
  // the panel using a WrapLayout.
  if (size.equals(preferredLayoutSize)) {
    super.layoutContainer(target);
  } else {
    preferredLayoutSize = size;
    Container top = target;
    while (top.getParent() != null) {
      top = top.getParent();
    }
    top.validate();
  }
}

代码示例来源:origin: danmbox/briss2

/**
 * Layout the components in the Container using the layout logic of the
 * parent FlowLayout class.
 * 
 * @param target
 *            the Container using this WrapLayout
 */
@Override
public final void layoutContainer(final Container target) {
  Dimension size = preferredLayoutSize(target);
  // When a frame is minimized or maximized the preferred size of the
  // Container is assumed not to change. Therefore we need to force a
  // validate() to make sure that space, if available, is allocated to
  // the panel using a WrapLayout.
  if (size.equals(preferredLayoutSize)) {
    super.layoutContainer(target);
  } else {
    preferredLayoutSize = size;
    Container top = target;
    while (!(top instanceof Window) && top.getParent() != null) {
      top = top.getParent();
    }
    top.validate();
  }
}

代码示例来源:origin: stackoverflow.com

flowLayout.layoutContainer(container);
panelTop.add(subPanel);
container.add(panelTop, BorderLayout.NORTH);

相关文章