public void update() {
    List<RadComponent> selection = myMainArea.getSelection();
    if (selection.size() != 1) {
      if (myCaption != null) {
        myCaption = null;
        myRootComponent.setLayout(null);
        myRootChildren = Collections.emptyList();
        myArea.deselectAll();
        revalidate();
        repaint();
      }
      return;
    }

    boolean update = !myRootChildren.isEmpty();

    IntList oldSelection = null;
    if (myCaption != null) {
      oldSelection = new IntArrayList();
      for (RadComponent component : myArea.getSelection()) {
        oldSelection.add(myRootChildren.indexOf(component));
      }
    }

    myArea.deselectAll();
    myRootComponent.setLayout(null);

    ICaption caption = null;
    RadComponent component = selection.get(0);
    RadComponent parent = component.getParent();

    if (parent != null) {
      caption = parent.getLayout().getCaption(component);
    }
    if (caption == null) {
      caption = component.getCaption();
    }

    if (caption == null) {
      myRootChildren = Collections.emptyList();
    }
    else {
      myRootComponent.setLayout(caption.getCaptionLayout(myMainArea, myHorizontal));

      myRootChildren = caption.getCaptionChildren(myMainArea, myHorizontal);
      for (RadComponent child : myRootChildren) {
        child.setParent(myRootComponent);
      }

      if (myCaption == caption) {
        List<RadComponent> newSelection = new ArrayList<>();
        int componentSize = myRootChildren.size();
        int selectionSize = oldSelection.size();

        for (int i = 0; i < selectionSize; i++) {
          int index = oldSelection.getInt(i);
          if (0 <= index && index < componentSize) {
            newSelection.add(myRootChildren.get(index));
          }
        }

        if (!newSelection.isEmpty()) {
          myArea.setSelection(newSelection);
        }
      }

      update |= !myRootChildren.isEmpty();
    }

    myCaption = caption;

    if (update) {
      revalidate();
      repaint();
    }
  }
public void update()