I'm trying to listen to the list view's scrollbar change. My first attempt is to do like this
listView.setOnScroll(new EventHandler<ScrollEvent>()
{ // Code ommited }
However it doesn't seem to be work. I try to use the debugger and found that the handle method in EventHandler hash't been called.
I have searched for other solution and found this one (https://gist.github.com/jewelsea/1684622) which is work, however it doesn't work if I move the for each loop to the position before primaryStage.show(). So this one is not the ideal solution for my use case since I've split my UI code into many subcomponent and I need to set the listener before calling primaryStage.show() (I don't won't to expose the listview instance to the main Application class).
I think that the problem is because the lookUpAll method work only if the node has already shown on the stage. I've think of some work around such as to do the foreach loop in a method which will be executed after the node is fully attached to the scene graph and is showed on to the screen, but still I don't know how to achieve this.
Thank you.