Changing content of HTMLDocument displayed in a JTextPane
Posted
by kayahr
on Stack Overflow
See other posts from Stack Overflow
or by kayahr
Published on 2010-05-22T14:45:17Z
Indexed on
2010/05/22
14:51 UTC
Read the original article
Hit count: 344
I'm displaying some tables as HTML code (rendered by a Freemarker template) with a JTextPane. I also have some HTML links in this HTML output which can be used to interact with the values of the table (For example "Delete a row" and stuff like this). Currently I always recreate the whole HTML output on each change and replace the whole document in the JTextPane with the new one. This is getting really slow and the JTextPane always changes the scroll position when I do this.
Is it possible to change only parts of the HTML code during runtime without replacing the whole document? In a real browser I would use the DOM and do something like document.getElementById("price").innerHTML = "$123.44". Is something like that possible with the HTMLDocument in a JTextPane?
© Stack Overflow or respective owner