• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Saving and loading data of a Jtable

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey I'm pretty new to this forum, and to Java itself.
I am trying to make a program where a user can enter guests name for a hotel, the JTable includes rows for the name of the tenant, the room number, month etc.
I've made the table, however I am having some trouble in saving the data that I put into the table. I used jtextfield and a jbutton to but data into the jtable. I am trring to save the data, and load it just buy clicking a button.
This is my basic table.

And what I'm trying to do to save the data is:

When I run my program, I'm able to click on a button, and the dialog box will appear, I'm also able to save the data to a file. However when I click on the retieve data button I made the dialog box opens, the file is there, however when I click it, nothing happens.
Any help will be much appreciated.
Thanks
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


When you save the data you are saving a DefaultTableModel.



When you read the data you are trying to read in a Vector? Why a Vector, you saved a DefaultTableModel? You can't just randomly change the type of data in the saved object.

So read in a DefaultTableModel. Once you read the model you need to add the model to the table:

 
reply
    Bookmark Topic Watch Topic
  • New Topic