Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

saving program settings--need some sample code

 
brown shoes
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if the Properties class will do the trick. You can use it to store and load a set of name value pairs.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic