boolean (MouseWheelEvent event) { var source = (JScrollPane)event.getSource(); // do not process any event from JBScrollPane with this option if (ClientProperty.isTrue(getViewportView(source), JBScrollPane.IGNORE_SCROLL_LATCHING)) { return false; } myScrollEvents.add(new MyScrollEvent(event.getWhen(), event.getPreciseWheelRotation(), event.isShiftDown())); double xs = 0.0, ys = 0.0; var iterator = myScrollEvents.iterator(); while (iterator.hasNext()) { MyScrollEvent se = iterator.next(); if (se.when() + getExpireAfter() < event.getWhen()) { iterator.remove(); } else { if (se.isHorizontal()) { xs += Math.abs(se.rotation()); } else { ys += Math.abs(se.rotation()); } } } double angle = Math.toDegrees(Math.atan(Math.abs(ys / xs))); boolean isHorizontal = event.isShiftDown(); double thatAngle = getAngle(); if (angle <= thatAngle && !isHorizontal || angle >= 90 - thatAngle && isHorizontal) { return true; } return false; }