Swing and path

W

wbrzozow

Hello
I have the following problem. I have been writing a Swing application.
In this application in several places I use JFileChooser. I try to
find a pattern or a good solution for remembering path to directory
for each place, where the JFileChooser was used. In order to meet my
boss requirements my application after lunching should remember paths
that were used before.

I hope that is clear, because my English isn’t very good.

Waldek
 
V

Valdeva Crema

Hello
I have the following problem. I have been writing a Swing application.
In this application in several places I use JFileChooser. I try to
find a pattern or a good solution for remembering path to directory
for each place, where the JFileChooser was used. In order to meet my
boss requirements my application after lunching should remember paths
that were used before.

I hope that is clear, because my English isn’t very good.

Waldek

One approach could be to save it off as a properties file. Jakarta
has an abundance of Java tools and they happen to have a property
persistence tool: http://commons.apache.org/configuration/howto_properties.html

You can save the properties file to a place on the user's computer and
then load it when the program opens.

Hope this helps!
Dee Dee
 
R

Roedy Green

I have the following problem. I have been writing a Swing application.
In this application in several places I use JFileChooser. I try to
find a pattern or a good solution for remembering path to directory
for each place, where the JFileChooser was used. In order to meet my
boss requirements my application after lunching should remember paths
that were used before.

see http://mindprod.com/jgloss/jfilechooser.html
for the code
 
C

Chase Preuninger

Well, u spelled launch wrong, but other than that you had good
english. What you basically could do is every time the user selects
ok and clicks a file you set a variable to what that file's directory
was then when your program exits (you could put this code in the close
method of a WindowListener on you main frame) you simply write the
data to a log file. Then every time you program loads you can read
this file in and set all your file dialogs to start at this directory
or the last file chosen.
 
W

wbrzozow

I would use Preferences instead of doing this.  It's what they are meant
for.


I am thinking about advantages and disadvantages both solutions :
Preferences and Apache Properties. I probably use Preferences, but a
have only one question. Where the configuration data are stored in
Linux, Unix system.
 
W

wbrzozow

I am thinking about advantages and disadvantages both solutions :
Preferences and Apache Properties. I probably use Preferences, but a
have only one question. Where the configuration data are stored in
Linux, Unix system.
 
H

Hendrik Maryns

(e-mail address removed) schreef:
I am thinking about advantages and disadvantages both solutions :
Preferences and Apache Properties. I probably use Preferences, but a
have only one question. Where the configuration data are stored in
Linux, Unix system.

http://mindprod.com/jgloss/properties.html

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFIBzC/e+7xMGD3itQRApFmAJ9lsY+KOLCQBH/ThJq69+Xi9j4lmwCcDcmH
iIwQR5ASlvp51t+GpfbfxPE=
=uZ/n
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top