(Adding Object Serialization to the MyShape Drawing Application) Modify Exercise 12.17 to allow the user to save a drawing into a file or load a prior drawing from a file using object serialization....



(Adding Object Serialization to the MyShape Drawing Application)

Modify Exercise 12.17



to allow the user to save a drawing into a file or load a prior drawing from a file using object serialization. Add buttons
Load
(to read objects from a file) and
Save
(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 the
Load
and
Save
buttons, 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 the
Save
button.




May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here