aspose file tools*
The moose likes Java in General and the fly likes Ok, how do common apps do this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Ok, how do common apps do this?" Watch "Ok, how do common apps do this?" New topic
Author

Ok, how do common apps do this?

Doyle Matt
Ranch Hand

Joined: Jul 05, 2004
Posts: 76
I'm about to do an app that actually saves it state. For example, my app has a
checkbutton in it, an supposing i enabled it and then closed the swing app, how will i make the app so that the next time it starts the checkbutton is still enabled or disabled depending on the last time i used it?

Is this where serialization takes place?


SCJP 1.4
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

No, I wouldn't use serialization for this, I'd just use a Properties file. See the java.util.Properties class. Make up a property name like "doodad.checkbox.state" and set its value to "true" or "false" in the application's Properties object when you dismiss the dialog box. It's best to have a class whose job it is to wrap the Properties, and save it to disk whenever a value changes.


[Jess in Action][AskingGoodQuestions]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
You should also take a look at the Preferences API: http://java.sun.com/j2se/1.4.2/docs/guide/lang/preferences.html


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Doyle Matt
Ranch Hand

Joined: Jul 05, 2004
Posts: 76
Thanks guys!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ok, how do common apps do this?