to allow the user to save a drawing into a file or load a prior drawing from a file using object serialization. Add buttonsLoad(to read objects from a file) andSave(to write objects to a file). Use an ObjectOutputStream to write to the file and an ObjectInputStream to read from the file. Write the array of MyShape objects using method writeObject (class ObjectOutputStream), and read the array using method readObject (ObjectInputStream). The object-serialization mechanism can read or write entire arrays—it’s not necessary to manipulate each element of the array of MyShape objects individually. It’s simply required that all the shapes be Serializable. For both theLoadandSavebuttons, use a JFileChooser to allow the user to select the file in which the shapes will be stored or from which they’ll be read.When the user first runs the program, no shapes should be displayed on the screen. The user can display shapes by opening a previously saved file or by drawing new shapes. Once there are shapes on the screen, users can save them to a file using theSavebutton.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here