• Post Reply Bookmark Topic Watch Topic
  • New Topic

Saving and loading jtable data  RSS feed

 
Latif Hemid
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I made a small program. And there is no problem saving the data but when I load them there is nothing in the jtable. I have seen some sample codes in the forum but could not solve the problem of my Can I have any help? Here is the code:

 
Rodion Gork
Ranch Hand
Posts: 47
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you add debugging about the line 68, do you see the data are really loaded into vector variable?

And by the way, don't you need updating the frame after that? I'm sorry for the last time I wrote swing apps was about 3 years ago
 
Latif Hemid
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, but I didn't quite understand what you said about line 68
 
Rodion Gork
Ranch Hand
Posts: 47
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I meant - could we check the data are loaded from file really:

E.g. something like this:



So that you can see in console that vectors of proper size are really loaded.
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have two "tableModel" variables. One local variable and the other is an instance variable.

The local variable is added to the table. The instance variable is reference in your load method so the data just sits in memory.

Get rid of the local variable. That is get rid of the first line of code. That statement makes the variable local when all you is one instance variable.
 
Latif Hemid
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much Rob Camick. Finally it worked. You are right I have deleted the first line and I got want I want.
I am a self learner and new to Java. Because of working, I could not take much time to practice. Thank God there are helpfull friends out there.
 
Latif Hemid
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, one more thing , it worked great. The thing is My jTable header was editable. and It could not save the edited jtable header. I mean , I changed the name of the header and saved it. But when I load it there is no change on the header.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!