Avoiding MONSTEROUS overkill in Serialization?

I have a JTextPane that I need to serialize. All I really need to save is the x,y,height,width, and the marked-up text from the field. (font, size, color, bold, italic.) A test case I set up should have taken about 100 to 120 bytes to capture every bit of data I need. Yet when I serialize the instance it ends up writing a file that's 18K long and filled with mountains, foothills, and gently rolling fields of irrelevant data.

That would not be such a problem, except that my actual application has dozens and dozens of JTextPanes in the same application that all need to be saved together into a single XML file. Is there an easy way just to extract the marked-up text from a JTextPane without the truckloads of superfluous garbage that serialize insists on including?

Want I would really dearly love to have is a StyledDocument to HTML conversion, but no such thing seems to exist, so I need to figure out how to grab the data and write such a conversion.

Thanks,

--gary

[1006 byte] By [fiziwiga] at [2007-10-3 2:48:34]
# 1

May be you can use XMLEncoder to stor as XML. But obviously you will not be able to select which properties are saved and which are not so if you need more control you will need to implementsomething on your own.

something like this

public class ConfigUtil{

public void saveConfiguration(JTextPane jtp, String id){

//Save the setting that you want to save someware against the specified ID

}

public void configure(JTextPane jtp, String id){

//Fetch the settings using the ID and set them to the geven jtp

}

}

LRMKa at 2007-7-14 20:37:21 > top of Java-index,Core,Core APIs...