how to save the table columns state?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Aleksey_Skorokhodov
Posted On:   Tuesday, April 2, 2002 12:17 AM

I have a JTable. I would like to save its state when user exits the application. I know how to save the table model - it's easy :). The problem I have for now is - where (how?) to store the table column model? store the headers in tablemodel? I think it's not good to use a code like this: String[] headers = {"From", "Subject", "Date", "Size"}; DefaultTableModel data = new DefaultTableModel(headers, 0) because I'd like to manipulate the columns freely. Maybe I should create my own MailTableColumnModel, I suppose I should use somethink like class MailTableColumnModel extends DefaultTableColumnModel This va   More>>

I have a JTable. I would like to save its state when user exits the application. I know how to save the table model - it's easy :).
The problem I have for now is - where (how?) to store the table column model? store the headers in tablemodel?


I think it's not good to use a code like this:

			
String[] headers = {"From", "Subject", "Date", "Size"};
DefaultTableModel data = new DefaultTableModel(headers, 0)


because I'd like to manipulate the columns freely.
Maybe I should create my own MailTableColumnModel,
I suppose I should use somethink like
			
class MailTableColumnModel extends DefaultTableColumnModel


This variant of code is being compiled OK, tablecolumnmodel is stored OK,
but my table is NOT visible.
I'll try to explain:
I have a JTable with
1) datamodel which really contains data
2) tablecolumnmodel with 2 columns
but the table is not visible. Ehh.. maybe my question is not so clear?..
Maybe I should add columns definitions both in datamodel in columnmodel?..    <<Less

Re: how to save the table columns state?

Posted By:   Aleksey_Skorokhodov  
Posted On:   Wednesday, April 3, 2002 12:03 AM

Let me clarify my question.
It seems to me that tableModel does not store columns properties (width, names, ...).
I have a table (JTable). I want this JTable to display information from different table models depending on a user selection.
Also I want to allow a user to change these tables columns' width.
So, what should I store to make these tables have different columns width? As for now, the data from different models is displayed ok depending on a user selection, but the columns changes are not stored from table to table.
About | Sitemap | Contact