Click to See Complete Forum and Search --> : Read file into Tablemodel


phoenix
May 3rd, 2000, 03:41 AM
Hi there,

I'm new to Swing and I have problem with Jtable. I want to create a Jtable with a model. After it has been created, I want to be able to add data to the table. However, I want to save my data to a file. When I run the program again I want the file to be loaded into the table and perform all possible operations (add, midify and delete).
How to accomplish this?

Thanks in advance!

Barry

May 3rd, 2000, 04:16 AM
Hello,

JTable is created using Model View Architecture. Here Model and view are sepereted.

For this you have to create your own Table Model class which extends AbstractTableModel class. To store the data you have to create a data Structure which hold the data. In the getValue of the Table Model class return the value from the DataStructure. When you close the application you can clone the Datastructure and store it in the HardDisk. And when you start you application, you can read the file and fill the datastructure. When you want to modify your table modify your DataStructure and repaint the table.

Hope you get what i am saying
yerneni@indya.com

phoenix
May 3rd, 2000, 04:48 AM
Hello there,

Thank you for your reply. However, I know what I have to do, I just don't know how to do it. What I'm looking for is an example. I've searched the net but I couldn't find any examples. Does anyone have an example? If so, please, mail it to me.

Thanks in advance!

Grtx,

Barry