スクロールバーの範囲を計算に追加する必要があります。以下の例では、コードをコードに追加しました。
scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent ae) {
int extent = scrollPane.getVerticalScrollBar().getModel().getExtent();
System.out.println("Value: " + (scrollPane.getVerticalScrollBar().getValue()+extent) + " Max: " + scrollPane.getVerticalScrollBar().getMaximum());
}
});
2つの代替実装(部分的にKleopatraに反応)
scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent event) {
JScrollBar scrollBar = (JScrollBar) event.getAdjustable();
int extent = scrollBar.getModel().getExtent();
System.out.println("1. Value: " + (scrollBar.getValue() + extent) + " Max: " + scrollBar.getMaximum());
}
});
またはモデル経由
scrollPane.getVerticalScrollBar().getModel().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent event) {
BoundedRangeModel model = (BoundedRangeModel) event.getSource();
int extent = model.getExtent();
int maximum = model.getMaximum();
int value = model.getValue();
System.out.println("2. Value: " + (value + extent) + " Max: " + maximum);
}
});