=== modified file 'src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiButton.java' --- src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiButton.java 2015-11-27 18:10:35 +0000 +++ src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiButton.java 2015-12-23 10:35:20 +0000 @@ -30,6 +30,7 @@ ** we have to track the mouse release, not click. Adding auto-scroll feature on ** press and hold mouse button. The mouse executor shoule be stopped on widget ** destroy to free the resources. Changing static executor to be instance based. +** 012 SBI 20151223 Emits only valid auto scroll events. */ package com.goldencode.p2j.ui.client.gui; @@ -246,8 +247,11 @@ // emit the sequential scroll events ScrollEvent evt = ((ScrollBarGuiImpl)owner).createAutoScrollEvent(position); - - tc.postOSEvent(evt); + + if (evt != null) + { + tc.postOSEvent(evt); + } } } catch (InterruptedException ex) === modified file 'src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiImpl.java' --- src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiImpl.java 2015-11-27 18:10:35 +0000 +++ src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiImpl.java 2015-12-23 10:46:56 +0000 @@ -40,6 +40,7 @@ ** to scroll - it is not required to draw the thumb. Fix for background drawing. ** 019 EVL 20151125 Adding executor shutdown to prevent resource leak. Changing static executor ** to be instance based. +** 020 SBI 20151223 Changed createAutoScrollEvent() to create only valid auto scroll events. */ package com.goldencode.p2j.ui.client.gui; @@ -749,23 +750,42 @@ } /** - * Create GUI specific auto-scroll event. - * - * @param btn - * The source button that caused the event. + * Create GUI specific auto-scroll event if the changed position is valid, otherwise it returns + * null indicating that it is not required to send scroll events due to the current scroller's + * position reaches its bounds. + * + * @param btn + * The source button that caused the event. + * + * @return Returns the valid scroll event if the current scroller's position doesn't reach + * its bounds, otherwise null. */ public ScrollEvent createAutoScrollEvent(Position btn) { + if (position >= max && btn == ScrollBar.Position.RIGHT + || position <= 0 && btn == ScrollBar.Position.LEFT) + { + return null; + } + // start with the current position int newPos = position; - + if (btn == ScrollBar.Position.RIGHT) { newPos += shortStep; + if (newPos > max) + { + newPos = max; + } } else { newPos -= shortStep; + if (newPos < 0) + { + newPos = 0; + } } return createScrollEvent(newPos);