我正在尝试制作一个聊天框应用程序,我正在尝试对侧边栏进行编码,以便它将保留在底部,但也可以向上滚动以查看历史记录。有什么办法可以做到这一点吗?
pane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
}
});
最佳答案
, im trying to code the side bar so that it will stay at the bottom but can also scroll up to view history
查看 Smart Scrolling 。当滚动条位于底部时,它会在添加下一个文本时保留在那里。如果您滚动到其他位置,它会停留在那里(即使添加了新文本),直到您将滚动条移回底部。
关于java - 当滚动条位于底部时将其滚动到底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26416171/