import javafx.application.Application; import javafx.geometry.VPos; import javafx.scene.Scene; import javafx.scene.text.Text; import javafx.stage.Stage; import javafx.scene.Group; import javafx.scene.shape.PathElement; import javafx.scene.shape.Path; public class BrokenSelection extends Application { public static Path textSelection(final Text text, int startSelection, int endSelection) { text.setImpl_selectionStart(startSelection); text.setImpl_selectionEnd(endSelection); PathElement[] selectElements = text.getImpl_selectionShape(); Path selectPath = new Path(); selectPath.getElements().addAll(selectElements); return selectPath; } @Override public void start(Stage stage) { stage.setWidth(400); stage.setHeight(600); Scene scene = new Scene(new Group()); Group group = (Group) scene.getRoot(); Text text = new Text("The quick brown fox jumps over the lazy dog. Woven silk pyjamas exchanged for blue quartz?"); text.setTextOrigin(VPos.TOP); text.setWrappingWidth(200); // Text selection test group.getChildren().add(textSelection(text, 1, 55)); group.getChildren().addAll(text); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); } }