How to serialize a window or form

Maybe serialization is not supposed to work this way, but I want to serialize an entire window (objects and all) to a file, and then de-serialize...this code is close:

void saveIt() {

try {

FileOutputStream out = new FileOutputStream("file.dat");

ObjectOutputStream s = new ObjectOutputStream(out);

s.writeObject(myWindow );

s.flush();

s.close();

myWindow .dispose();

} catch(IOException ioe) {

System.err.println("Save failed!");

ioe.printStackTrace();

}

};

void openIt() {

try {

FileInputStream in = new FileInputStream("file.dat");

ObjectInputStream s = new ObjectInputStream(in);

JInternalFrame myWindow = (JInternalFrame)s.readObject();

in.close();

myWindow .show();

} catch(Exception e) {

System.err.println("Load failed!");

e.printStackTrace();

}

};

When I debug this, the 'myWindow ' reference after loading seems to be valid, and I can actually add objects to it...but it's just not there! I also tried 'repaint' and 'pack' and other methods to try to get the window to show up, but to no avail.

I also tried XMLEncode and decode with similar (but different) results...

Anybody?

Thank you,

JR

Message was edited by:

johnrule

Fixed a typo...

[1371 byte] By [johnrulea] at [2007-10-3 3:44:26]
# 1
What about serializing a runtime class?Possible?<JR>
johnrulea at 2007-7-14 21:40:37 > top of Java-index,Core,Core APIs...
# 2
maybe you could try myWindow.setVisible( true );
Joraha at 2007-7-14 21:40:37 > top of Java-index,Core,Core APIs...