繁体   English   中英

如何使HtmlEditor默认文本在javafx中为空

[英]How to make HtmlEditor default text to empty in javafx

我有HTMLEditor,默认情况下,在该htmleditor中,我正在获取<html><head></head><body></body></html>文本。 因此,无论何时我在编辑器中找到长度,最低我要达到62。但是如何知道HTMLEditor是否为空

只需将初始htmlText参数设置为空字符串

@FXML
HTMLText text;

private void initialize() {
    text.setHtmlText("");
}

或直接在FXML文件中

<HTMLEditor htmlText=""/>

快速实用的方法是清除这些文本

htmleditor.getHtmlText()
       .replace("<html><head></head><body>", "")
       .replace("</body></html>", "")
       .isEmpty();

但是如果你想要的HTML内容真实空虚那么它是一个有点硬。 用“ java html strip tag”关键字搜索网络。

暂无
暂无

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

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