Reputation: 1002
At the time of scroll bar visible or occur I want to fire an event. Till now what I've done is
private ScrollBar getVerticalScrollbar()
{
ScrollBar result = null;
for (Node n : scrollPaneID.lookupAll(".scroll-bar"))
{
if (n instanceof ScrollBar)
{
ScrollBar bar = (ScrollBar) n;
if (bar.getOrientation().equals(Orientation.VERTICAL))
{
result = bar;
}
}
}
return result;
}
ScrollBar bar = getVerticalScrollbar();
through this I can check if the scroll bar is appear or not
if(bar.isVisible())
{
}
but it works only after the scrollbar is visible. My requirement is fire event when scrollbar is appear
Upvotes: 1
Views: 1108
Reputation: 2186
You can try adding a ChangeListener to visible property.Something like below but this will fire every time its visibility changes so put your logic inside the changed method very carefully according to your requirement
result.visibleProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(final ObservableValue<? extends Boolean> observableValue, final Boolean aBoolean, final Boolean aBoolean2) {
System.out.println("Scrol Pane visible");
}
});
Upvotes: 1