public Dimension preferredLayoutSize(Container parent) {
   return LayoutUtil.add(
       useSelectedComponentSize
           ? component == null ? new Dimension(0, 0) : component.getPreferredSize()
           : LayoutUtil.getMaxPreferredSize(parent.getComponents()),
       parent.getInsets());
 }
  public void layoutContainer(Container parent) {
    Component[] c = parent.getComponents();
    Insets parentInsets = parent.getInsets();
    Dimension size = LayoutUtil.getInteriorSize(parent);

    for (int i = 0; i < c.length; i++) {
      c[i].setBounds(parentInsets.left, parentInsets.top, size.width, size.height);
    }
  }
  public void showComponent(Component c) {
    final Component oldComponent = component;

    if (oldComponent == c) return;

    component = c;

    boolean hasFocus =
        oldComponent != null
            && LayoutUtil.isDescendingFrom(
                KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(),
                oldComponent);

    if (oldComponent != null) oldComponent.setVisible(false);

    if (component != null) {
      component.setVisible(true);

      if (hasFocus)
        // component.requestFocusInWindow();
        ComponentUtil.smartRequestFocus(component);
    }

    /*    if (oldComponent != null) {
    //      oldComponent.setVisible(false);
          SwingUtilities.invokeLater(new Runnable() {
            public void run() {
              if (oldComponent.getParent() == container && oldComponent != component) {
                oldComponent.setVisible(false);
              }

    //          FocusUtil.unblockFocusChanges();
            }
          });
        }*/
  }
 public Dimension maximumLayoutSize(Container target) {
   return LayoutUtil.add(LayoutUtil.getMinMaximumSize(target.getComponents()), target.getInsets());
 }
 public Dimension minimumLayoutSize(Container parent) {
   return LayoutUtil.add(LayoutUtil.getMaxMinimumSize(parent.getComponents()), parent.getInsets());
 }