@Override
        public void layoutContainer(Container parent) {
          Dimension size = getSize();
          mainPanel.setSize(size);
          mainPanel.validate();

          if (IdeEventQueue.getInstance().getTrueCurrentEvent().getID() == MouseEvent.MOUSE_DRAGGED) {
            Dimension preferredSize = preferredLayoutSize(null);
            if (preferredSize.width != size.width) {
              UISettings.getInstance().setMaxLookupWidth(Math.max(500, size.width));
            }

            int listHeight = myList.getLastVisibleIndex() - myList.getFirstVisibleIndex() + 1;
            if (listHeight != myList.getModel().getSize() &&
                listHeight != myList.getVisibleRowCount() &&
                preferredSize.height != size.height) {
              myLookup.getPresentation().setMaxVisibleItemsCount(listHeight);
            }
          }

          myList.setFixedCellWidth(myScrollPane.getViewport().getWidth());
        }
@Override
        public void layoutContainer(Container parent)