java - How to know mouseDragged direction - when it's up or down? -


finishing create custom scrollbar, , question is:

addmousemotionlistener(new mousemotionadapter() {     @override     public void mousedragged(mouseevent e) {          //how know mouse direction - or down?      } }); 

maybe there simple method, or have manually?

you have manually need mouseadapter instead of mousemotionadapter record initial y co-ordinate.

addmousemotionlistener(new mouseadapter() {      int previousy;      @override     public void mousepressed(mouseevent e) {         previousy = e.gety();     }      @override     public void mousedragged(mouseevent e) {          int y = e.gety();         if (y < previousy) {             system.out.println("up");         } else if (y > previousy) {             system.out.println("down");         }          previousy = y;     } }); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -