简体   繁体   中英

How to remember the user decision from the last implementation of a program

I have to creata a Dialog in Java with few fields like customer Id, name etc. The behaviour of the dialog is that customer(s) can be selected by a check box and can be saved and closed. When the next time the user opens the dialog all the customers that have been previously selected should be seen selected and when the user selects a few new customers and presses the save button then only the new user are displayed.

So, my question is what are the ways in Java by which my application sees and remember what happened during the last run of the program and uses those old values during the recent run of it.

Two immediate questions which come into my mind now is that in what format shall i save the current customer values when the dialog is saved.

and

Which API/classes do i have to retreive those particular values from whatever file/ format they are saved in

Create a Initialisation file, if the save checkbox is checked, save your info into this file, preferably after encryption. When your program starts up, check for info in the initialisation file, if any info exists, read it.

You should serialize the objects whose state you need to maintain after program restart. When your program restarts deserialize all those objects and then use those deserialized objects for initializing the state of your objects.

Have a look at serialization in java for a breif tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM