0

I'm having an issue with a JFXSlider and a ScrollPane. Since I don't like the default style of the scrollbar, I'm using a JFXSlider to move the ScrollPane up and down.

slider.valueProperty().addListener((ChangeListener) ->
        scrollPane.setVvalue(Math.abs(slider.getValue() - 100) / 100));

This piece of code works just fine, but when I add content to the ScrollPane, it stays in its place. I would like to move it to the bottom. I've tried changing the position of the ScrollPane after inserting the contents, but it does nothing.

anchorPane.localToScene();
scrollPane.setVvalue();

I also tried to bind the ScrollPane vValue to the height of the vBox that it has inside and it worked, but the JFXSlider stopped working

scrollPane.vvalueProperty().bind(vBox.heightProperty());

I would like to have both working at the same time, but I don't know if it's possible. I've heard about bindBidirectional, but I don't know how to use it in this case.

Thanks in advance.

KeepoN
  • 137
  • 1
  • 11

1 Answers1

0

If you ensure the range of your slider is the same as the vertical range of your scroll pane, which you can do with

slider.minProperty().bind(scrollPane.vminProperty());
slider.maxProperty().bind(scrollPane.vmaxProperty());

then you can just bidirectionally bind the slider's value to the scrollpane's vertical value:

slider.valueProperty().bindBidirectional(scrollPane.vvalueProperty());

(I don't use JFoenix, and I can't find any meaningful documentation for it, so I'm just assuming here that a JFXSlider has the same properties as a standard Slider.)

James_D
  • 201,275
  • 16
  • 291
  • 322