Does anyone know how to generate an HTMLDocument object programmatically in Java without resorting to generating a String externally and then using HTMLEditorKit#read to parse i
It appears that you can accomplish what you are attempting using direct construction of HTMLDocument.BlockElement
and HTMLDocument.BlockElement
objects. Theses constructors have a signature that suggests direct use is possible, at least.
I would suggest examining the Swing sources in OpenJDK to see how the parser handles this, and derive your logic from there.
I would also suggest that this optimization may be premature, and perhaps this should be a speed-optimized replacement for a simpler approach (i.e. generating the HTML text) only introduced if this really does become a performance hotspot in the application.