import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.ScrollPane; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.FlowPane; import javafx.scene.layout.VBox; import javafx.scene.text.Text; import javafx.stage.Stage; import javafx.util.Duration; /** * * @author Alexander Kouznetsov */ public class Bug extends Application { public static void main(String[] args) { launch(args); } int counter = 0; @Override public void start(Stage stage) throws Exception { final FlowPane root = new FlowPane(); final Scene scene = new Scene(root); stage.setScene(scene); stage.show(); final VBox vBox = new VBox(5); ScrollPane scrollPane = new ScrollPane(); scrollPane.setStyle("-fx-background-color: black;"); scrollPane.setContent(vBox); Scene scene2 = new Scene(scrollPane); // scene2.setFill(Color.BLACK); Stage stage2 = new Stage(); stage2.setScene(scene2); stage2.show(); Timeline timelineRenderToImage = new Timeline(new KeyFrame(Duration.millis(10), new EventHandler() { @Override public void handle(ActionEvent t) { // comment out the following two lines to verify it is affecting // rendering Image image = Image.impl_fromPlatformImage(scene.renderToImage(null)); vBox.getChildren().add(new ImageView(image)); } }), new KeyFrame(Duration.millis(10), new EventHandler() { @Override public void handle(ActionEvent t) { if (counter % 10 == 0) { root.getChildren().clear(); } else { root.getChildren().add(new Text((counter % 10) + " ")); } counter++; } })); timelineRenderToImage.setCycleCount(100); timelineRenderToImage.play(); } }