简体   繁体   English

行距HTMLEditor JavaFx

[英]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. 我想使用css规则调整JavaFx中HTMLEditor的行高,但找不到该规则的名称。 I tried -fx-line-height and a few other but none of them worked. 我尝试了-fx-line-height和其他一些功能,但是没有一个起作用。 Is it even possible, or is the HTMLEditor too restricted? 甚至有可能,还是HTMLEditor太受限制了?

The HTML editor edits HTML, you need to specify the line-height in HTML based CSS (not JavaFX CSS). HTML编辑器编辑HTML,您需要在基于HTML的CSS (不是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);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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