File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

Joined: Jul 08, 2003
Posts: 24199

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

Joined: Jul 11, 2001
Posts: 14112
You should also take a look at the Preferences API:

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:
subject: Ok, how do common apps do this?
It's not a secret anymore!