Link to home
Start Free TrialLog in
Avatar of pelau
pelauFlag for Canada

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.NotSerializableException: javax.swing.text.JTextComponent$InputMethodReq
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?
Avatar of Jim Cakalic
Jim Cakalic
Flag of United States of America image

How are you writing out the document? Can you post the relevant code?
Avatar of pelau

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.getSelectedFile();
ObjectOutputStream objOut = new ObjectOutputStream(new FileOutputStream(fileName));
objOut.writeObject(jeditorPane);
objOut.flush();


//and loading back the object:

MyJEditor mj = (MyJEditor)objIn.readObject();
c.add(mj, BorderLayout.CENTER);
ASKER CERTIFIED SOLUTION
Avatar of Jim Cakalic
Jim Cakalic
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pelau

ASKER

thanks, I will try the editorkit thing .