Reputation: 25
Method sp.setVvalue(app.spvalue.intValue());
doesn't scroll vbox to desired position.
mvPane = new VBox();
mvPane.setStyle("-fx-background-color: #fff;");
GetPlayList(app,root);
sp = new ScrollPane();
sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
sp.setContent(mvPane);
sp.setVvalue(40);
setCenter(sp);
sp.getVvalue();
Function GetPlayList adds many labels.
Upvotes: 1
Views: 8831
Reputation: 900
In this case the issue surely was the number 40, as only values between 0 and 1 are allowed. However stumbled across this question while having the same issue for a different reason.
Found out that it is important that setHvalue()
and setVvalue
are executed only on the JavaFX thread:
(that is, within Platform.runlater
). For example:
Platform.runLater(() - > {
scrollPane.setHValue(0.0);
});
Otherwise the position is not visibly updated until a user-driven scroll-event is initiated.
Upvotes: 0
Reputation: 145
This might be your problem - I noticed that if you try to do yourScrollPane.setVvalue()
before doing yourStage.show()
, it will NOT scroll. However, it will work if sp.setVvalue()
is executed after the stage is already shown. Not sure if that's a bug in ScrollPane or intended behavior. Hope that helps.
Upvotes: 0
Reputation: 3654
If you are talking about JavaFX 2.0, and its scrollPane, then Hvalue and Vvalue properties are working well, but the matter, look like, that their values are doubles from range [0.0 .. 1.0], so, when you set int value, it will not work fine.
Upvotes: 4