JScrollPane mouse-wheel area

て烟熏妆下的殇ゞ 提交于 2019-12-11 05:56:58

问题


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!


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/7202028/jscrollpane-mouse-wheel-area

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!