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 saving program settings--need some sample code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "saving program settings--need some sample code" Watch "saving program settings--need some sample code" New topic

saving program settings--need some sample code

brown shoes

Joined: May 04, 2003
Posts: 1
I creating a text editor program which allows the user to change the background color of the textarea, font color, and font type. I want to allow the changes to be saved from session to session. Does anyone have any sample code? I have never done this before.
John Lee
Ranch Hand

Joined: Aug 05, 2001
Posts: 2545
set default value for background color and font size at the beginning of each session. then change them as you like, set the value accordingly. when next user open a new window, default value get used again.
can anyone provide sample code please?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
See if the Properties class will do the trick. You can use it to store and load a set of name value pairs.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
If you can assume JDK 1.4 or better, the new Preferences API seems to fit the bill quite nicely. For sample code, see The Java Almanac.
- Peter
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

"brown shoes"-
Welcome to the JavaRanch!
We like to keep a nice professional lookin' image here (despite that one eyed moose)... so please adjust your displayed name to match the JavaRanch Naming Policy. You can change it here.
Thanks! and again, welcome to the JavaRanch!
I agree. Here's the link:
subject: saving program settings--need some sample code
jQuery in Action, 3rd edition