boolean (@NotNull MouseEvent e, @NotNull JScrollBar bar) { if (e.getID() == MouseEvent.MOUSE_MOVED || e.getID() == MouseEvent.MOUSE_PRESSED) { ScrollBarUI ui = bar.getUI(); if (ui instanceof BasicScrollBarUI bui) { try { Rectangle rect = (Rectangle)ReflectionUtil.getDeclaredMethod(BasicScrollBarUI.class, "getThumbBounds", ArrayUtil.EMPTY_CLASS_ARRAY).invoke(bui); Point point = SwingUtilities.convertPoint(e.getComponent(), e.getX(), e.getY(), bar); return !rect.contains(point); } catch (Exception e1) { return true; } } else if (ui instanceof DefaultScrollBarUI dui) { Point point = e.getLocationOnScreen(); SwingUtilities.convertPointFromScreen(point, bar); return !dui.isThumbContains(point.x, point.y); } } return true; }