aspose file tools*
The moose likes Beginning Java and the fly likes Remember last file opened Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Remember last file opened" Watch "Remember last file opened" New topic
Author

Remember last file opened

mark geroso
Greenhorn

Joined: Oct 12, 2006
Posts: 24
My Prof assigned this project... A frame, text area in the center, panel in the south containing a text field. Any text file opened would show its contents in the text area and the path and filename in the text field.

I did it, but I can't figure out how to make it remember which file was last opened.
Say, you run the program, open a text file, save and close the file, then close the program. If you run the program again, it will open the last file accessed automatically.
I thought about assigning the path to a string variable, but won't all variables be cleared when you close the program?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Yes. You'd have to save the path into a little preferences file for your program, loaded when your program starts up.


[Jess in Action][AskingGoodQuestions]
mark geroso
Greenhorn

Joined: Oct 12, 2006
Posts: 24
Thanks. I was thinking of that, I was just hoping there would be a more elegant solution.
I'm gonna go do that now.
 
jQuery in Action, 2nd edition
 
subject: Remember last file opened