Help coderanch get a
new server
by contributing to the fundraiser
  • 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 3324
32
  • 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: 22791
131
Eclipse IDE Spring 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
 
No holds barred. And no bars holed. Except this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic