1

Simple question, probably an equally simple answer - yet I can't find it in documentation:

My current implementation uses a MouseListener on JScrollPane's ScrollBars to detect a user scrolling action. However, on a MacBook, a user can also use the trackpad (double finger drag) to modify the position of the JViewport's View without using the ScrollBars. How can I programmatically detect this?

More: There are several (unanswered) questions asking for ways to detect trackpad gestures. It seems that may not be possible in "plain old Java". I am seeking a solution that doesn't care which specific user action caused the scroll to take place, but instead detects that the JViewport's position over the View has changed. The JScrollPane is somehow informed to perform a scroll action when the trackpad gesture occurs, so I am hoping to avoid detecting how it happened (which may in this case not be possible) but instead detecting the resulting effect of the user input happening.

Continued searching, just found this: Java trackpad 2-finger scroll listener which indicates that one approach may be to use a MouseWheelListener. That's still detecting the user input rather than the result, but may be a workable option I will explore.

Community
  • 1
  • 1
ags
  • 719
  • 7
  • 23

0 Answers0