File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes AdjustmentListener on JScrollBar always returns event TRACK Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "AdjustmentListener on JScrollBar always returns event TRACK" Watch "AdjustmentListener on JScrollBar always returns event TRACK" New topic
Author

AdjustmentListener on JScrollBar always returns event TRACK

Corrie L Sherone
Greenhorn

Joined: Jan 21, 2008
Posts: 17
I have a dead simple test program that creates a JScrollbar, adds an AdjustmentListener and prints out the event types as they occur. From what I read in the api, I was expecting to see different events in the console when I clicked on an arrow vs clicking on the track. But the console always displays AdjustmentEvent.TRACK ie 5. Am I missing something simple?

Corrie L Sherone
Greenhorn

Joined: Jan 21, 2008
Posts: 17
Doh, I was reading the wrong section of the docs. Seems the behavior is a bug, or by design, depending on how you look at it. Not the answer I wanted, but at least now I know.

Bug 4075484 "When user scroll ScrollPane, we receive notifications in native code. Then we propogate these notifications to Java code by issuing PeerEvent which calls setValue() ... The problem is that there is no way to pass scroll-type to setValue()"

JScrollBar "Note that the AdjustmentEvents type property will always have a placeholder value of AdjustmentEvent.TRACK because all changes to a BoundedRangeModels value are considered equivalent.."
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: AdjustmentListener on JScrollBar always returns event TRACK
 
Similar Threads
JTable ListSelectionListener
JScrollBar that takes doubles
enabling the scrollbar when components are dynamically added in jpanel
Mouse events on JScrollBar arrows?
JSlider shud fire change event only when it comes to rest