简体   繁体   中英

Line spacing HTMLEditor JavaFx

I would like to adjust the line height of an HTMLEditor in JavaFx with css rules but can't find the name of the rule. I tried -fx-line-height and a few other but none of them worked. Is it even possible, or is the HTMLEditor too restricted?

The HTML editor edits HTML, you need to specify the line-height in HTML based CSS (not JavaFX CSS).

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;

public class SpacedOut extends Application {

    private static final String HTML_TEXT =
            "<p style=\"line-height:1.5\">\n" +
            "    <span style=\"font-size:12pt\">The quick brown fox jumps over the lazy dog.</span><br />\n" +
            "    <span style=\"font-size:24pt\">The quick brown fox jumps over the lazy dog.</span>\n" +
            "</p>";

    @Override
    public void start(Stage stage) throws Exception{
        HTMLEditor editor = new HTMLEditor();
        editor.setHtmlText(HTML_TEXT);

        Scene scene = new Scene(new Pane(editor));
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM