Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Scrolling with mouse wheel in scrollpane without scrollbar  RSS feed

 
M Bryan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have a very thin panel in which the user should navigate with his mouse wheel. a scroll bar should only be shown when the user activates it (e.g. when he has no mouse wheel).
the problem now is: when the scrollbar is shown, scrolling with the mouse wheel works fine. but when it's removed (via setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER)), it is not possible anymore to scroll with the mouse wheel.

how can i fix this problem?

thanks in advance
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you expect it to be scrollable when there is no scrollbar? Or am I misunderstanding your question?
 
M Bryan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want it always to be possible to scroll with the mouse wheel, even if the scrollbar is not visible, like in the case, when the users made them invisible because they dont need it
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a bit tricky, because the scroll pane's UI delegate is coded to not scroll when the scrollbar isn't visible. Here's a hack around that -- use at your own risk, I haven't really tested it beyond seeing that it re-enables scrolling.

 
Paul Clapham
Sheriff
Posts: 22503
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have never seen a UI component like this. Perhaps it's not possible... have you ever seen such a component?
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of setting the scrollbar policy to "never", another hack would be:

 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would vertical.setVisible(false) also work?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably not, as isVisible() would return false.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!