I have a JFileChooser and I want to controll it with gestures. What I have done so far is to measure the speed of the swiping gesture and send a signal as from the mouse wheel. Here is my code:
private void mouseWheelMove(SwipeGesture swipe){
if (swipe.direction().getX() < 0){
if (swipe.speed()< 1000f){
robot.mouseWheel(1);
}
if (swipe.speed()>=1000f && swipe.speed() < 3000f){
robot.mouseWheel(2);
}
if (swipe.speed()>=3000f && swipe.speed() < 4500f){
robot.mouseWheel(3);
}
if (swipe.speed()>=4500f){
robot.mouseWheel(4);
}
}
if(swipe.direction().getX() > 0){
if (swipe.speed()< 1000f){
robot.mouseWheel(-1);
}
if (swipe.speed()>=1000f && swipe.speed() < 3000f){
robot.mouseWheel(-2);
}
if (swipe.speed()>=3000f && swipe.speed() < 4500f){
robot.mouseWheel(-3);
}
if (swipe.speed()>=4500f){
robot.mouseWheel(-4);
}
}
}
Is there any other way to do this? Because the movement is very rough. I wanted it to scroll very slow when I swipe very slow etc. But it just jumps to the end of the scroll bar. Can somebody give me a hint?