行间距HTMLEditor JavaFx [英] Line spacing HTMLEditor JavaFx

查看:298
本文介绍了行间距HTMLEditor JavaFx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用css规则调整JavaFx中HTMLEditor的行高,但找不到规则的名称。
我试过 -fx-line-height 和其他一些但没有一个有效。甚至可能,还是HTMLEditor受限制?

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?

推荐答案

HTML编辑器编辑HTML,你需要指定基于HTML的CSS中的行高(不是JavaFX CSS)。

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);
    }
}

这篇关于行间距HTMLEditor JavaFx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆