AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Text Fields

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
aeh
Guest





PostPosted: Mon Jun 20, 2005 7:12 pm    Post subject: Text Fields Reply with quote



I am writing a gui and want my program to remember the values that have
been stored in the textfields after the user exits the program so that
when the user restarts the program he does not have to re-type the
data. I am new to using Java and was told that there was a class that
would allow me to do this. Any hints would be appreciated.

Back to top
Eric Sosman
Guest





PostPosted: Mon Jun 20, 2005 7:48 pm    Post subject: Re: Text Fields Reply with quote





aeh wrote:
Quote:
I am writing a gui and want my program to remember the values that have
been stored in the textfields after the user exits the program so that
when the user restarts the program he does not have to re-type the
data. I am new to using Java and was told that there was a class that
would allow me to do this. Any hints would be appreciated.

java.util.Properties may be what you need.

--
[email]Eric.Sosman (AT) sun (DOT) com[/email]


Back to top
Andrew Thompson
Guest





PostPosted: Mon Jun 20, 2005 7:51 pm    Post subject: Re: Text Fields Reply with quote



On 20 Jun 2005 12:12:57 -0700, aeh wrote:

Quote:
I am writing a gui and want my program to remember the values that have
been stored in the textfields after the user exits the program so that
when the user restarts the program he does not have to re-type the
data. I am new to using Java and was told that there was a class that
would allow me to do this. Any hints would be appreciated.

You need Java's I/O functionality. There are a number
of ways (using different classes) you can use.
Check here for a good overview.
<http://java.sun.com/docs/books/tutorial/essential/io/>

..... The following answer is what I put when I thought
you were talking about user program preferences specifically.
It might (or might not) better answer your question.

There are a variety of classes that might be of help.

Is this an application? (unstrusted Applets have security restrictions.)

The easiest is possibly the Preferences[1] class, which
is a Java 1.4+ class to store/retrieve preferences.
I have not had cause to use the preferences API as yet.

[1]
<http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html>

There are also other ways to store program preferences.

You can create a custom class that stores the relevant attributes,
then use object serialisation[2] to write it to disk and retrieve it.
If your custom class is also a bean, you can use the
XMLDecoder/Encoder[3] classes introduced in 1.4.

[2] <http://java.sun.com/j2se/1.5.0/docs/guide/serialization/>

[3]
<http://java.sun.com/j2se/1.5.0/docs/api/java/beans/XMLDecoder.html>
<http://java.sun.com/j2se/1.5.0/docs/api/java/beans/XMLEncoder.html>

HTH

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane

Back to top
Real Gagnon
Guest





PostPosted: Tue Jun 21, 2005 12:36 am    Post subject: Re: Text Fields Reply with quote

Quote:
I am writing a gui and want my program to remember the values that have
been stored in the textfields after the user exits the program so that
when the user restarts the program he does not have to re-type the
data. I am new to using Java and was told that there was a class that
would allow me to do this. Any hints would be appreciated.

Look at the java.util.prefs package.

Examples at http://javaalmanac.com/egs/java.util.prefs/pkg.html

Bye.
--
Real Gagnon from Quebec, Canada
* Looking for Java or PB code examples ? Visit Real's How-to
* http://www.rgagnon.com/howto.html

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.