問題描述
奇怪的是 JScrollPane
沒有方法 addAdjustmentListener()
.然而,adjustmentListener 據(jù)說是與滾動條一起使用的.每當(dāng) JScrollPane
以任何一種方式滾動時,我都希望發(fā)生一些事情.如何實現(xiàn)這樣的事情?
It's strange that JScrollPane
doesn't have a method addAdjustmentListener()
. Yet adjustmentListener is said to be used with scrollbars. I want something to happen whenever the JScrollPane
is scrolled in either way. How to achieve such a thing?
推薦答案
為什么不獲取實際的滾動條,然后向它們添加調(diào)整偵聽器?JScrollBar
有一個名為 addAdjustmentListener()
的方法.
Why don't you get the actual scrollbars, and then add adjustment listeners to them? JScrollBar
has a method called addAdjustmentListener()
.
您可以使用 getVerticalScrollBar()
和 getHorizo??ntalScrollBar()
從 JScrollPane
中獲取 JScrollBar
And you can use getVerticalScrollBar()
and getHorizontalScrollBar()
to get a JScrollBar
from a JScrollPane
這篇關(guān)于JScrollPane 的滾動事件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!