Package org.fxmisc.richtext

Examples of org.fxmisc.richtext.StyleClassedTextArea


        launch(args);
    }

    @Override
    public void start(Stage stage) {
        StyleClassedTextArea area = new StyleClassedTextArea();
        area.setWrapText(true);
        area.appendText("Pause the mouse over the text for 1 second.");

        Popup popup = new Popup();
        Label popupMsg = new Label();
        popupMsg.setStyle(
                "-fx-background-color: black;" +
                "-fx-text-fill: white;" +
                "-fx-padding: 5;");
        popup.getContent().add(popupMsg);

        area.setMouseOverTextDelay(Duration.ofSeconds(1));
        area.addEventHandler(MouseOverTextEvent.MOUSE_OVER_TEXT_BEGIN, e -> {
            int chIdx = e.getCharacterIndex();
            Point2D pos = e.getScreenPosition();
            popupMsg.setText("Character '" + area.getText(chIdx, chIdx+1) + "' at " + pos);
            popup.show(area, pos.getX(), pos.getY() + 10);
        });
        area.addEventHandler(MouseOverTextEvent.MOUSE_OVER_TEXT_END, e -> {
            popup.hide();
        });

        Scene scene = new Scene(area, 600, 400);
        stage.setScene(scene);
View Full Code Here

TOP

Related Classes of org.fxmisc.richtext.StyleClassedTextArea

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.