/* * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. */ package bugs.richtext; import javafx.application.Application; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.scene.text.Text; import javafx.scene.text.TextFlow; import javafx.stage.Stage; /** * * @author Andrey Glushchenko */ public class BigVerticalObjectLineBreakTestApp extends Application { private static int WIDTH = 500; private static int HEIGHT = 500; private static int FLOW_HEIGHT = 402; private static int FLOW_WIDTH = 402; public Pane getPane() { Pane root = new Pane(); root.setStyle("-fx-background-color: green;"); root.setPrefHeight(HEIGHT); root.setPrefWidth(WIDTH); root.setMinHeight(HEIGHT); root.setMinWidth(WIDTH); root.setMaxHeight(HEIGHT); root.setMaxWidth(WIDTH); TextFlow tf = new TextFlow(); tf.setStyle("-fx-border-color: red;-fx-background-color: white;"); tf.setPrefHeight(FLOW_HEIGHT); tf.setPrefWidth(FLOW_WIDTH); tf.setMinHeight(FLOW_HEIGHT - 30); tf.setMinWidth(FLOW_WIDTH - 30); tf.setMaxHeight(FLOW_HEIGHT + 30); tf.setMaxWidth(FLOW_WIDTH + 30); prepareCase(tf); root.getChildren().add(tf); return root; } protected void prepareCase(TextFlow tf) { tf.getChildren().add(new Rectangle(60, 10)); Rectangle rect = new Rectangle(); rect.setHeight(FLOW_HEIGHT / 2 - 30); rect.setWidth(30); rect.setFill(Color.AQUA); rect.setStroke(Color.BLUE); tf.getChildren().add(rect); tf.getChildren().add(new Text("\n")); tf.getChildren().add(new Rectangle(140, 10)); rect = new Rectangle(); rect.setHeight(FLOW_HEIGHT / 2 - 30); rect.setWidth(30); rect.setFill(Color.AQUA); rect.setStroke(Color.BLUE); tf.getChildren().add(rect); } @Override public void start(Stage stage) throws Exception { Scene scene = new Scene(getPane(), WIDTH, HEIGHT); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }