I want to show the last item added in the table view when appears a scroll bar. Is there any way for the same and it will be grateful if can.
I have checked scroll pane with horizontal and vertical setValue() property. Is there any similar way for the table view scroll bar?
Check the TableView.scrollTo() out.
Here is a full generic solution:
public static <S> void addAutoScroll(final TableView<S> view) {
if (view == null) {
throw new NullPointerException();
}
view.getItems().addListener((ListChangeListener<S>) (c -> {
c.next();
final int size = view.getItems().size();
if (size > 0) {
view.scrollTo(size - 1);
}
}));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With