……
jScrollPane = new JScrollPane(infoArea);
……
//自动滚动方法
public void scrollToView(){
if(jScrollPane != null && infoArea != null){
Point p = new Point();
if (!infoArea.getScrollableTracksViewportHeight()) {
p.setLocation(0, infoArea.getHeight());
this.jScrollPane.getViewport().setViewPosition(p);
}
}
}
本文介绍了一个简单的自动滚动功能实现方法,通过判断条件并设置视口位置,使得文本区域能够在滚动条存在的情况下自动滚动到最底部。
1万+

被折叠的 条评论
为什么被折叠?



