I require my JScrollBar to trigger a repaint, when the mouse is released from the bar. I managed to solve this by adding a MouseListener to the JScrollBar object, and just implementing the mouseReleased method.
But the problem is that when the 2 ends of the JScrollBar(the unit increment/decrement things) are released, it does not recognise this as a mouse release, and mouseReleased(...) is never invoked.
I tried to remove the 2 end things, to just leave the bar, but I couldn't seem to do this, is there any other way to solve this problem?
Basically when mouse is held on the scrollbar, or its end things.. I need it to trigger a certain repaint (say repaint1), But when mouse is released from scrollbar, or its end things.. I need it to trigger a different repaint (say repaint2).
I tried using your code as well as having an AdjustmentListener on my scrollbar (implementing adjustmentValueChanged(AdjustmentEvent ae)), but it doesnt work well. After moving scrollbar, then releasing it, repaint1 and repaint2 are both called, where I just require repaint2. And when mouse is held over the 2 end things of scrollbar, both repaint1 and repaint2 are invoked.. ( repaint1,repaint2,repaint1,repaint2,repaint1,repaint2,...) When I just require repaint1, while mouse is held on it, and repaint2, when it is released.