JScrollPane鼠标滚轮区域 [英] JScrollPane mouse-wheel area

查看:159
本文介绍了JScrollPane鼠标滚轮区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我里面有一个JScrollPaneJPanel.我在需要时会看到滚动条,但只有在鼠标悬停在滚动条上时,鼠标滚轮才起作用.当鼠标指针(而不只是滚动条)位于整个面板上时,是否存在使鼠标滚轮工作的属性或其他功能?您知道,就像在浏览器中一样-即使鼠标指针不在滚动条上,您也可以滚动页面.

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.

提前谢谢!

推荐答案

它适用于我(Java 6,Windows,包含JPanel的JScrollPane,将鼠标移到JPanel上).具有圆形100个像素边框的JPanel,最小尺寸为1000x1000,首选尺寸为(4000x4000).

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.

这篇关于JScrollPane鼠标滚轮区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆