0
私はScrollPaneの子であるanchorPaneを持っています。今、私は、anchorPaneをスケールするボタンを持っています。これは、ボタンがズームエフェクトを作成することを意味します。ただし、anchorPaneに別のディメンションがある場合、scrollPaneは変更されたanchorPaneのサイズを認識せず、スクロールバーも大きくなりません。ここに私のコードです:スクロールバーはスケールペインと対話しません
public class View implements Observer{
private Model model;
private Stage stage;
private Button plus;
private Button minus;
Affine affine = new Affine();
ScrollPane scrollPane;
public View (Model model, Stage stage) {
model.addObserver(this);
this.model = model;
this.stage = stage;
this.plus = new Button("+");
this.minus = new Button("-");
HBox hBox = new HBox(2);
VBox vBox = new VBox();
AnchorPane anchorPane = new AnchorPane();
SVGPath svgTest = new SVGPath();
svgTest.setContent(model.getShapes());
anchorPane.getChildren().add(svgTest);
anchorPane.getTransforms().add(affine);
scrollPane = new ScrollPane(anchorPane);
scrollPane.setFitToHeight(true);
scrollPane.setFitToWidth(true);
scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
hBox.getChildren().add(plus);
hBox.getChildren().add(minus);
SplitPane root = new SplitPane(scrollPane);
root.setOrientation(Orientation.VERTICAL);
root.setDividerPositions(0.85);
scrollPane.setVvalue(1.0d);
root.getItems().add(hBox);
Scene scene = new Scene(root, 1000, 1000);
stage.setScene(scene);
stage.setTitle("myStage");
stage.show();
}
public Stage getStage() {
return stage;
}
public Button getZoomPlusButton() {
return plus;
}
public Button getZoomMinusButton() {
return minus;
}
public void zoomPlus() {
affine.append(new Scale(1.1, 1.1));
}
public void zoomMinus() {
affine.append(new Scale(0.9, 0.9));
}
@Override
public void update(Observable o, Object arg) {
}
}
どうすれば問題を解決できますか?
ありがとうございます。
ありがとうございました。 :-)これは確かに私が探していた解決策であり、私の問題を解決します。 – Toti