@Override
      protected void handlePopup(MouseEvent e) {
        super.handlePopup(e);
        JPopupMenu popup = tabs.getActivePopup();
        if (popup != null) {
          popup.addPopupMenuListener(new PopupMenuListenerAdapter() {
            @Override
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
              handle();
            }

            @Override
            public void popupMenuCanceled(PopupMenuEvent e) {
              handle();
            }

            private void handle() {
              popup.removePopupMenuListener(this);
              actionPanel.setVisible(!showCloseActionOnHover() || isHovered());
            }
          });
        }
      }
@Override
      protected void handlePopup(MouseEvent e)