0
试图使用JavaFX StackPane
的snapshot
方法捕获“背景”元素。我特别感兴趣的节点的背景(顾名思义)。JavaFX快照不捕获背景
如果我设置我的场景与StackPane
,背景字面上是ImageView
下我想显示,然后一切工作正常。但是,如果我使用更直观的节点功能setBackground
并尝试捕获快照,它(背景)不显示。
例如可正常工作,如果你做getBackgroundNode().snapshot(new SnapshotParameters(), null)
:
private Node getBackgroundNode() {
ImageView background = new ImageView(new Image("https://www.yamaha-motor.ca/images/pages/products/units/MC/action/2016_FZ_07_2_l.jpg"));
Rectangle2D viewport = new Rectangle2D(0, 0, 1080, 720);
background.setViewport(viewport);
return background;
}
但是,下面的方法不显示我的背景,当我打电话snapshot
方法。
private Node getBackgroundNode() {
Image background = new Image("https://www.yamaha-motor.ca/images/pages/products/units/mc/action/2016_fz_07_2_l.jpg");
StackPane stack = new StackPane();
stack.setBackground(new Background(new BackgroundImage(background, null, null, null, null)));
stack.setPrefSize(1080, 720);
return stack;
}
这是否只是snapshot
方法的一个特点?我看了一下SnapshotParameters
,没有任何明显的设置可以让我捕捉背景。