Reputation: 115
I have a couple of line charts inside GridPane:
@FXML
private GridPane LineChartVBox = new GridPane();
And this is my Scrollbar:
ScrollBar sc = new ScrollBar();
sc.setMin(0);
sc.setOrientation(Orientation.VERTICAL);
hbox1.getChildren().addAll(LineChartVBox,sc);
sc.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov,
Number old_val, Number new_val) {
LineChartVBox.setLayoutY(-new_val.doubleValue());
}
});
I have a problem with the scrollbar because it does not do anything and I can not even see the end to it.
Here is the example of it:
Upvotes: 0
Views: 623
Reputation: 91
I agree with VGR you should use a ScrollPane. However its seems your ScrollBar is too height, you can try :
sc.maxHeightProperty().bind(scene.heightProperty());
I copy-paste your code and your Listener is working, I had'nt tested with the same HBox and I suppose its also the HBox which fix the position of the GridPane.
You can try to bind()
manually your ScrollBar position, but you can may be try to use LineChartVBox.setTranslateY(-new_val.doubleValue());
Upvotes: 2