DefaultTableModel() is a crap / How to hide a Table column?

M

Mark Sizzler

It all started with my search for a possibility to store data values in a JTable without displaying it.
I read somewhere in the Sun docs that columns without a header are not displayed.
Ok, I thought, according to a good coding style they are not displayed but they are stored.
But what a crap, the data is even worse deleted. See the simplified scenario below:

String rowData[][] = {
{ "firstrowfirstcol", "firstrowsecondcol" },
{ "secondrowfirstcol", "secondrowsecondcol" }
};

String columnNames[] = {
"col1head"
};

DefaultTabelModel mytm = new DefaultTableModel(rowData, columnNames);

After performing the last command not only mytm does not contain the values of the second column
but also the values of the second column are removed from the rowData!!!
What a poor system architecture. It costs me a half day to find it out because I could not believe it.

Do I really have to setup a storage outside of DefaultTableModel to be able to store
additional data ?

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top