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
Post a Comment