将JScrollPane滚动到底部 [英] Scroll JScrollPane to bottom

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

问题描述

我需要将JScrollPane滚动到底部。 JScrollPane包含一个JPanel,其中包含许多JLabel。

I need to scroll a JScrollPane to the bottom. The JScrollPane contains a JPanel, which contains a number of JLabel's.

要滚动到顶部,我只是这样做:

To scroll to the top, I just do:

scrollPane.getViewport().setViewPosition(new Point(0,0));

但如何精确滚动到最底部? (太多而且紧张不安)

but how do I scroll exactly to the very bottom? (Too far and it jitters)

推荐答案

JScrollBar vertical = scrollPane.getVerticalScrollBar();
vertical.setValue( vertical.getMaximum() );

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

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