简体   繁体   中英

How to make HtmlEditor default text to empty in javafx

I am having HTMLEditor, in that htmleditor by default i am getting <html><head></head><body></body></html> text. So when ever i am finding length in editor , minimum i am getting 62. But how to know whether HTMLEditor is empty or not

Just set initial htmlText argument to an empty string

@FXML
HTMLText text;

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

Or directly in FXML file

<HTMLEditor htmlText=""/>

The quick and practical way is to clear those texts

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

However if you want a real emptiness of html content then it is a little hard. Search the net with "java html strip tag" keywords.

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