无法识别的问题。
当尝试在setLayout
范围之外应用旋转和ScrollPane
时,文本的一部分会显示在anchorPaneForScene
上,即使在滚动时,文字仍然是静态的
代码和图像会更清晰
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
public class example extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
AnchorPane anchorPaneForScene=new AnchorPane();
ScrollPane scrollPane=new ScrollPane();
scrollPane.setLayoutY(100);
scrollPane.setPrefSize(300,300);
anchorPaneForScene.getChildren().add(scrollPane);
Scene scene=new Scene(anchorPaneForScene,800,500);
AnchorPane anchorPaneForScroll=new AnchorPane();
anchorPaneForScroll.setPrefSize(400,800);
scrollPane.setContent(anchorPaneForScroll);
Text text=new Text("JAVAFX");
Rotate rotate=new Rotate();
rotate.setAxis(Rotate.Y_AXIS);
rotate.setAngle(-30);
scrollPane.setContent(anchorPaneForScroll);
anchorPaneForScroll.getChildren().add(text);
text.getTransforms().add(rotate);
text.setFont(Font.font(80));
text.setLayoutY(30);
text.setLayoutX(30);
primaryStage.setScene(scene);
primaryStage.show();
}
}
输出