JScrollPane mouse-wheel area
Asked Answered
R

2

1

I have a JScrollPane and a JPanel inside. I see the scrollbars when needed, but the mouse wheeling works only when the mouse is over the scrollbars. Is there a property or something to make mouse wheeling work when the mouse pointer is over the whole panel, not just the scrollbars? You know like in browsers - you can scroll the page even if the mouse pointer is not over the scrollbars.

Thanks in advance!

Rifling answered 26/8, 2011 at 8:35 Comment(0)
S
2

It works for me (Java 6, Windows, JScrollPane containing a JPanel, mouse wheeling over JPanel). JPanel with rounded 100 pixel borders, min size 1000x1000, preferred size (4000x4000).

So I guess, that your existing code interferes. Try a separate example, and then rework your app.

Spraddle answered 26/8, 2011 at 9:7 Comment(1)
I had a MouseWheelMoved listener. When I removed it, everything worked fine. Thanks:)Rifling
E
1

Make sure main window(possibly a JFrame) implements Scrollable.

Ethyl answered 26/8, 2011 at 8:53 Comment(2)
@mKorbel - I am now confused if this is a standard functionality of JScrollPane. Why should I implement Scrollable? Joop Eggen says it is a standard one. I will look again at my code.Rifling
@Petar Minchev that's right, remove all MouseWheel & NouseMotionListeners at firstCaliper

© 2022 - 2024 — McMap. All rights reserved.