I currently wrote a small program for a manager at work. It inputs an invoice number and creates that into a button, going down in a row. Then inputs a date of approval and creates that into a label(on line with the created button). Lastly, creates a label for the date of expire(30 days later)(and again, online with the button created).
It saves this data into 3 files(1 for the button, 1 for the first label and one for the second label). Right now I’m using “ObjectOutputStream” to save the lists of buttons/labels. When the program is opened it re-loads all the data from the files and “re-prints” them onto the screen. The program also gives the user the option of deleting ROs in which case I re-write the data files minus the removed RO.
I am just wondering if there is a better way to do all this and if I’m wasting my time using this approach.
You should be saving data, not components. Can you construct the buttons, labels, etc on load and only save invoice numbers, date of approval, and date of expiry?
Also, you could store all data in an arraylist or hashmap and only save that object, rather than 1000’s of smaller objects.