Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

saving and reading data  RSS feed

 
Davy Kelly
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey everyone,

I have a for loop that makes an array of JTextAreas which ar stored in panels.

I want to be able to store data that is put into the JTextAreas and read data and populate the areas if something has been saved on load up.
here is my loop


here is my save code:


here is my listener class for the saving:


what am I doing wrong?
could you point my in the right direction?

davy

[ March 10, 2007: Message edited by: Davy Kelly ]
[ March 11, 2007: Message edited by: Davy Kelly ]
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Davy Kelly:

what am I doing wrong?


You need to Tell The Details. What do you expect to happen? What actually happens? Do you see an error/exception or do things fail silently?
 
Davy Kelly
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe

well in my program, the mySaveListener prints what I put in a JTextArea no problem to the display screen, it even loops through all of the JTextAreas nicely.

the method also creates a file called mydata.ser in the directory that this program is in. but nothing gets saved to this file. the file seems empty.

I do not get any errors compiling or running.

davy
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are saving all the strings to the same file. So after your loop is finished, the file is only going to contain the last string you wrote out. All the others are gone to the bit bucket and you will never see them again.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!