All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fxmisc.richtext.demo.lineindicator.LineIndicatorDemo Maven / Gradle / Ivy


package org.fxmisc.richtext.demo.lineindicator;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

import org.fxmisc.richtext.CodeArea;
import org.fxmisc.richtext.LineNumberFactory;
import org.fxmisc.richtext.StyledTextArea;

import java.util.function.IntFunction;

/**
 * 

Name: LineIndicatorDemo

*

Description: Written as a StackOverflow answer (2015) by Tomas Mikula, * which Jordan Martinez then extracted into this demo. * The author dedicates this file to the public domain. * Demonstrates the usage of {@link StyledTextArea#paragraphGraphicFactoryProperty()}. *

*

Comment: ... *

*

Copyright: Copyright (c) 2016-2019

*

Company: >StA-Soft<

* @author Tomas Mikula, StA * @version 1.0 */ public class LineIndicatorDemo extends Application { /** * Main-Methode. * @param args Kommandozeilenparameter */ public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { CodeArea codeArea = new CodeArea(); IntFunction numberFactory = LineNumberFactory.get(codeArea); IntFunction arrowFactory = new ArrowFactory(codeArea.currentParagraphProperty()); IntFunction graphicFactory = line -> { HBox hbox = new HBox(numberFactory.apply(line), arrowFactory.apply(line)); hbox.setAlignment(Pos.CENTER_LEFT); return hbox; }; codeArea.setParagraphGraphicFactory(graphicFactory); codeArea.replaceText("The green arrow will only be on the line where the caret appears.\n\nTry it."); codeArea.moveTo(0, 0); primaryStage.setScene(new Scene(new StackPane(codeArea), 600, 400)); primaryStage.show(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy