I am developing chat application on java and i want to use function used by facebook to retrieve chat history when user scroll up. I tried "on Scroll" action which fire event whenever scroll reach top or down of scroll bar. Now i want to Fire action event only when scroll bar reach top like in facbook chat box.
How to fire event when scrolling up,javafx
4.4k views Asked by AudioBubble At
2
There are 2 answers
0
On
Assuming that you have a ScrollPane
, you can observe vvalueProperty
of it:
scrollPane.vvalueProperty().addListener(
(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) -> {
if(newValue.doubleValue() == 0){
System.out.println( "AT TOP" );
// load more items
}
});
and you may also scroll to bottom with
scrollPane.setVvalue( scrollPane.getVmax() );
initially.
Here is the example of what you want. I hope this will help you.