public static <T> MouseMotionListener installAutoSelectOnMouseMove(@NotNull JList<T> list) {
    final MouseMotionAdapter listener = new MouseMotionAdapter() {
      boolean myIsEngaged = false;

      @Override
      public void mouseMoved(MouseEvent e) {
        Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        if (myIsEngaged && !UIUtil.isSelectionButtonDown(e) && !(focusOwner instanceof JRootPane)) {
          Point point = e.getPoint();
          int index = list.locationToIndex(point);
          list.putClientProperty(SELECTED_BY_MOUSE_EVENT, Boolean.TRUE);
          list.setSelectedIndex(index);
          list.putClientProperty(SELECTED_BY_MOUSE_EVENT, Boolean.FALSE);
        }
        else {
          myIsEngaged = true;
        }
      }
    };
    list.addMouseMotionListener(listener);
    return listener;
  }
public static <T> MouseMotionListener installAutoSelectOnMouseMove(@NotNull JList<T> list)