aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to scroll with the mouse horizontally Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to scroll with the mouse horizontally" Watch "How to scroll with the mouse horizontally" New topic
Author

How to scroll with the mouse horizontally

Olivier Legat
Ranch Hand

Joined: Nov 17, 2007
Posts: 176

Howdy folks

According to this thread the MouseWheelEvent class doesn't support horizontal scrolling. I've looked through the Java API and Google for alternatives but no luck.

Suggestions?

NOTE: I'm fairly sure it should be possible. Scrolling horizontally with the mouse works within a JScrollPane.

Thank-you


Olly
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
use a scrollpane and set vertical to never, then set horizontal scrollbar height to 0
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2175
    
    7
Michael Dunn wrote:use a scrollpane and set vertical to never, then set horizontal scrollbar height to 0


You don't need to set the horizontal scrollbar height to 0. At least not with the Metal LAF on JDK6. Unless, of course, your goal is to hide the horizontal scrollbar.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Unless, of course, your goal is to hide the horizontal scrollbar.

yes.

the OP states horizontal scrolling in a scrollpane is fine,
so I guessed perhaps he wants something without the scrollbar showing.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

I think Olivier simply wants to get an event when the user scrolls horizontally. For vertical scrolling there is MouseWheelListener with MouseWheelEvent, but there is no such thing for horizontal scrolling yet. There's already an accepted but unsolved bug report for that.

If the component itself supports horizontal scrolling then you can use an AdjustmentListener on the JScrollPane's horizontal scroll bar. This will be notified when the scroll bar's position changes, a side effect of the scrolling.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> I think Olivier simply wants to get an event when the user scrolls horizontally.

probably is what he wants, I was more going by his subject line "How to scroll with the mouse horizontally"

I still don't see the his problem though, the mouseWheelListener works for horizontal scolling, if there's
no vertical scrollbar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to scroll with the mouse horizontally