0

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?

Raistlin
  • 997
  • 2
  • 11
  • 33
  • You might me able to leverage the approach shown [here](http://stackoverflow.com/a/7203419/230513). – trashgod Oct 06 '13 at 18:00
  • Thanks for helping, but I need another solution. I don't build my own scrollbar, I use the scrollbar of the JFileChooser. – Raistlin Oct 07 '13 at 08:16

0 Answers0