pelau
asked on
saving/loading JEditorPane as an object
Hi there,
I have an application that has an JEditorPane area where I write text and draw basic shapes(circle, square). When saving the JEditorPane as an object to a file (after I typed some text)I have this error :
java.io.NotSerializableExc eption: javax.swing.text.JTextComp onent$Inpu tMethodReq
uestsHandler
anyway if I paste some text and not typping it I can save the object along with the graphic (e.g. circle)
The problem is when I am loading back the object I can see just the text I saved and not the circle as well...
Why is that?
I have an application that has an JEditorPane area where I write text and draw basic shapes(circle, square). When saving the JEditorPane as an object to a file (after I typed some text)I have this error :
java.io.NotSerializableExc
uestsHandler
anyway if I paste some text and not typping it I can save the object along with the graphic (e.g. circle)
The problem is when I am loading back the object I can see just the text I saved and not the circle as well...
Why is that?
How are you writing out the document? Can you post the relevant code?
ASKER
[...]
//saving the jeditorpane area
//I have omited try-catch for easy understanding
MyJEditor jeditorPane = new MyJEditor();
//this myjeditor is a derived class from JEditorPane.
File fileName = fileChooser.getSelectedFil
ObjectOutputStream objOut = new ObjectOutputStream(new FileOutputStream(fileName)
objOut.writeObject(jeditor
objOut.flush();
//and loading back the object:
MyJEditor mj = (MyJEditor)objIn.readObjec
c.add(mj, BorderLayout.CENTER);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks, I will try the editorkit thing .