@Override
      public void layoutContainer(Container parent) {
        super.layoutContainer(parent);

        int count = tabPane.getTabCount();
        if (count == 0) return;

        Component lastTabComponent = tabPane.getTabComponentAt(count - 1);
        if (lastTabComponent == null) return;

        Rectangle lastTabBounds = new Rectangle();
        getTabBounds(count - 1, lastTabBounds);
        Dimension preferredSize = myToolbarWrapper.getPreferredSize();
        Rectangle tabPaneBounds = tabPane.getBounds();
        int width = Math.min(preferredSize.width, tabPaneBounds.width - lastTabBounds.x - lastTabBounds.width);
        myToolbarWrapper.setBounds(lastTabBounds.x + lastTabBounds.width, lastTabBounds.y, width, preferredSize.height);
      }
@Override
      public void layoutContainer(Container parent)