I am wondering if it is possible to extract the HTML markup from a swing object once it has been set and displayed on the object.
For example, I can set the content type on a swing textpane to text/html and then set the text to be a html table within code with the .setText() method. The textpane then has a nice rendered HTML table displayed.
From here I would like to do the reverse and obtain the HTML markup that produced the table. I am having trouble getting the raw markup text back. I can only manage to get the rendered text which is devoid of the original markup.
i don't know of any way to get back the authentic html [perhaps a deep dump of the obj might reveal a secret cache], but - in theory - you should be able to reconstruct the meat of it by 'serializing' the Document obj. i'll explain.
as i understand it, java is able to do the rendering you are describing via model and view classes. the view is what gets rendered, the model is the nodal representation of the underlying html parse tree.
to make a long story short, i would try traversing "the structural portion of the subject that this view is mapped to" (ie. the document)
From the document root node (Element), you can traverse all the elements and attributes and 'serialize it' back to html.
there are classes to help with the serialization somewhere in javax.xml or org.xml .. you would use the relevant html dtd (or something simpler) for the schema.
i hope someone else can suggest a shorter way to do it...
I have a knack for fixing things like this ... um ... sorry ... here is a consilitory tiny ad:
a bit of art, as a gift, that will fit in a stocking