package rt; import javafx.application.Application; 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.paint.Color; import javafx.scene.shape.Rectangle; import javafx.scene.text.Text; import javafx.stage.Stage; public class RT_17572_BugRect extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { FlowPane root = new FlowPane(); Scene scene = new Scene(root); VBox vBox = new VBox(5); ScrollPane scrollPane = new ScrollPane(); scrollPane.setStyle("-fx-background-color: grey;"); scrollPane.setContent(vBox); Scene scene2 = new Scene(scrollPane); Stage stage2 = stage; // new Stage(); stage2.setScene(scene2); stage2.show(); if (1==1) { Rectangle text = new Rectangle(10,10); text.setFill(Color.RED); root.getChildren().add(text); Object img1 = scene.renderToImage(null); Image image1 = Image.impl_fromPlatformImage(img1); vBox.getChildren().add(new Text("Image #1:")); vBox.getChildren().add(new ImageView(image1)); Object img2 = scene.renderToImage(null); Image image2 = Image.impl_fromPlatformImage(img2); vBox.getChildren().add(new Text("Image #2:")); vBox.getChildren().add(new ImageView(image2)); } } }