/*
   *  Adjust the width of the scrollpane used by the popup
   */
  protected void popupWider(BasicComboPopup popup) {
    JList list = popup.getList();

    //  Determine the maximimum width to use:
    //  a) determine the popup preferred width
    //  b) limit width to the maximum if specified
    //  c) ensure width is not less than the scroll pane width

    int popupWidth =
        list.getPreferredSize().width
            + 5 // make sure horizontal scrollbar doesn't appear
            + getScrollBarWidth(popup, scrollPane);

    if (maximumWidth != -1) {
      popupWidth = Math.min(popupWidth, maximumWidth);
    }

    Dimension scrollPaneSize = scrollPane.getPreferredSize();
    popupWidth = Math.max(popupWidth, scrollPaneSize.width);

    //  Adjust the width

    scrollPaneSize.width = popupWidth;
    scrollPane.setPreferredSize(scrollPaneSize);
    scrollPane.setMaximumSize(scrollPaneSize);
  }
  /*
   *  I can't find any property on the scrollBar to determine if it will be
   *  displayed or not so use brute force to determine this.
   */
  protected boolean horizontalScrollBarWillBeVisible(
      BasicComboPopup popup, JScrollPane scrollPane) {
    JList list = popup.getList();
    int scrollBarWidth = getScrollBarWidth(popup, scrollPane);
    int popupWidth = list.getPreferredSize().width + scrollBarWidth;

    return popupWidth > scrollPane.getPreferredSize().width;
  }
  /*
   *  Get the scroll pane used by the popup so its bounds can be adjusted
   */
  protected JScrollPane getScrollPane(BasicComboPopup popup) {
    JList list = popup.getList();
    Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list);

    return (JScrollPane) c;
  }