How can I append text to webengine? I tried this:
public TabMessage(String title) {
super(title);
view = new WebView();
engine = view.getEngine();
engine.loadContent("<body></body>");
view.setPrefHeight(240);
}
private void append(String msg){
Document doc = engine.getDocument();
Element el = doc.getElementById("body");
String s = el.getTextContent();
el.setTextContent(s+msg);
}
But document is null
You can also use JavaScript to do the append.
I sometimes find it simpler to use jQuery to manipulate the DOM rather than the Java Document or native JavaScript DOM interfaces.
Whether you use the Java Document API, as Uluk has, or JavaScript or JQuery APIs, all of the other points in Uluk’s excellent answer still apply.