@@ -0,0 +1,3204 @@
+package org.fxmisc.richtext.demo;%0A%0Aimport javafx.application.Application;%0Aimport javafx.scene.Scene;%0Aimport javafx.scene.paint.Color;%0Aimport javafx.stage.Stage;%0Aimport javafx.util.Duration;%0Aimport org.fxmisc.richtext.CaretNode;%0Aimport org.fxmisc.richtext.InlineCssTextArea;%0Aimport org.fxmisc.richtext.Selection;%0Aimport org.fxmisc.richtext.SelectionImpl;%0Aimport org.fxmisc.richtext.SelectionPath;%0A%0Apublic class MultiCaretAndSelectionDemo extends Application %7B%0A%0A    @Override%0A    public void start(Stage primaryStage) throws Exception %7B%0A        String alphabet = %22abcdefghijklmnopqrstuvwxyz%22;%0A        StringBuilder sb = new StringBuilder();%0A        for (int i = 0; i %3C 10; i++) %7B%0A            sb.append(i).append(%22 :%22).append(alphabet).append(%22%5Cn%22);%0A        %7D%0A        InlineCssTextArea area = new InlineCssTextArea(sb.toString());%0A%0A        // create CSS styles%0A        String background = %22-rtfx-background-color: red; %22;%0A        String underline = %22-rtfx-underline-color: blue; %22 +%0A                           %22-rtfx-underline-width: 2.0;%22;%0A        String border = %22-rtfx-border-stroke-color: green; %22 +%0A                        %22-rtfx-border-stroke-width: 3.0;%22;%0A%0A        // set all of them at once on a give line to insure they display properly%0A        area.setStyle(0, alphabet.length(), background + underline + border);%0A%0A        // set each one over a given segment%0A        area.setStyle(1, 0, 3, background);%0A        area.setStyle(1, 4, 7, underline);%0A        area.setStyle(1, 8, 11, border);%0A%0A        // add another caret%0A        CaretNode extraCaret = new CaretNode(%22another caret%22, area);%0A        if (!area.addCaret(extraCaret)) %7B%0A            throw new IllegalStateException(%22caret was not added to area%22);%0A        %7D%0A        extraCaret.moveTo(3, 8);%0A%0A        // since the properties are re-set when it applies the CSS from files%0A        // remove the style class so that properties set above are not changed%0A        extraCaret.getStyleClass().remove(%22caret%22);%0A%0A        extraCaret.setStrokeWidth(10.0);%0A        extraCaret.setStroke(Color.BROWN);%0A        extraCaret.setBlinkRate(Duration.millis(200));%0A%0A        // add another selection%0A        Selection%3CString, String, String%3E extraSelection = new SelectionImpl%3C%3E(%22another selection%22, area,%0A                range -%3E %7B%0A                    SelectionPath p = new SelectionPath(range);%0A                    p.setStrokeWidth(0);%0A                    p.setFill(Color.YELLOW);%0A%0A                    // since the properties are re-set when it applies the CSS from files%0A                    // remove the style class so that properties set above are not changed%0A                    p.getStyleClass().remove(%22selection%22);%0A                    return p;%0A                %7D%0A        );%0A        if (!area.addSelection(extraSelection)) %7B%0A            throw new IllegalStateException(%22selection was not added to area%22);%0A        %7D%0A        extraSelection.selectRange(9, 2, 9, 8);%0A%0A        // select some other range with the regular caret/selection before showing area%0A        area.selectRange(2, 0, 2, 4);%0A%0A        primaryStage.setScene(new Scene(area, 400, 400));%0A        primaryStage.show();%0A%0A        // request focus so carets blink%0A        area.requestFocus();%0A    %7D%0A%7D%0A

Add demo displaying multiple carets and selections