@Override
  public void layoutContainer(Container container) {
    synchronized (container.getTreeLock()) {
      boolean logged = false;
      boolean updated = false;
      for (Component component : container.getComponents()) {
        if (component.isVisible()) {
          if (!updated) {
            updated = true;
            Dimension min = component.getMinimumSize();
            Dimension max = component.getMaximumSize();
            if (max.height < min.height) max.height = min.height;

            Rectangle bounds = new Rectangle(container.getWidth(), container.getHeight());
            JBInsets.removeFrom(bounds, container.getInsets());

            if (max.width < min.width) max.width = min.width;
            if (bounds.width > max.width) {
              bounds.x += (int)(.5f + (bounds.width - max.width) * component.getAlignmentX());
              bounds.width = max.width;
            }
            else if (bounds.width < min.width) {
              bounds.x += (int)(.5f + (bounds.width - min.width) * component.getAlignmentX());
              bounds.width = min.width;
            }
            if (max.height < min.height) max.height = min.height;
            if (bounds.height > max.height) {
              bounds.y += (int)(.5f + (bounds.height - max.height) * component.getAlignmentY());
              bounds.height = max.height;
            }
            else if (bounds.height < min.height) {
              bounds.y += (int)(.5f + (bounds.height - min.height) * component.getAlignmentY());
              bounds.height = min.height;
            }
            component.setBounds(bounds);
          }
          else {
            component.setVisible(false);
            if (!logged) {
              logged = true;
              Logger.getInstance(StatelessCardLayout.class).warn("too many visible components");
            }
          }
        }
      }
    }
  }
@Override
  public void layoutContainer(Container container)