public class AnimationFileSaver { public AnimationFileSaver(String filePath){ this( new File(filePath)); } public AnimationFileSaver(File file){ //save file try{ _tryToSave(file);} catch(java.io.IOException e){ e.printStackTrace(); } } private void _tryToSave(File file)throws java.io.IOException{ java.io.FileOutputStream stream = new java.io.FileOutputStream(file); java.io.ObjectOutputStream outputStream = new java.io.ObjectOutputStream(stream); //save data into file outputStream.writeObject(animationeditor.Controller.AnimationMainController.windowController); outputStream.writeObject(animationeditor.Controller.AnimationMainController.frameController); }}
and my loader class
public class AnimationFileLoader { public AnimationFileLoader(String filePath){ this( new File(filePath)); } public AnimationFileLoader(File file){ //save file try{ _tryToSave(file);} catch(java.lang.Exception e){ e.printStackTrace(); } } private void _tryToSave(java.io.File file)throws java.io.IOException, java.lang.ClassNotFoundException{ java.io.FileInputStream stream = new java.io.FileInputStream(file); java.io.ObjectInputStream inputStream = new java.io.ObjectInputStream(stream); //save data into file AnimationMainController.windowController = (AnimationWindowController)inputStream.readObject(); AnimationMainController.frameController = (OnionSkinningController) inputStream.readObject(); }}
The windowController contains the main app window, and the frame controller
has a list of frames used in th program. The above class works partially, but
not fully. The objects that were saved are loaded into the screen, but they
loose their capability of interactions with the user. More over, when I debug
it, my container that holds a list of shapes seems to be empty, but the screen
still shows the shape. Is there something more I should know about java.io.Serializable ? I could show more code, if I need to. Thanks.