Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How to scroll with the mouse horizontally

 
Ranch Hand
Posts: 176
Mac Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use a scrollpane and set vertical to never, then set horizontal scrollbar height to 0
 
Rancher
Posts: 3253
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> 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.
 
Sheriff
Posts: 22573
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic