permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes Mouse events on JScrollBar arrows? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Mouse events on JScrollBar arrows?" Watch "Mouse events on JScrollBar arrows?" New topic
Author

Mouse events on JScrollBar arrows?

Darrin Cartwright
Ranch Hand

Joined: Dec 27, 2002
Posts: 107
Hello All!

Does anyone know how to get mouse events from the arrow buttons on the end of a JScrollBar? I have tried this...

.. but the event is only fired when the mouse is pressed over the "Thumb" or track area of the JScollBar. I can't use an AdjustmentListener because the contents are changing dynamically at run time and I need to be able to differentiate between a user generated event and a change to the contents.

Any help is appreciated!

Thanks,

Darrin
[ December 21, 2005: Message edited by: Darrin Cartwright ]

Life is good on the Ponderosa,<br />but mind where you step.
Torgil Zethson
Greenhorn

Joined: Nov 30, 2005
Posts: 9
One straightforward way of doing it would be to traverse the component tree rooted at the JScrollBar. The buttons will be instances of javax.swing.BasicArrowButton (I think, but use JButton to be safe), so whenever you come across a child component that is an instance of that class you add your MouseListener.

Another approach would be to override the ScrollBarUI -- the buttons have protected access in BasicScrollBarUI.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mouse events on JScrollBar arrows?
 
Similar Threads
Disable Mouse Events
Capturing Mouse Events for invisible JWindow or JFrame
Action Event Problem
Basic Concepts of AWT Event Generation
JSlider shud fire change event only when it comes to rest