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

From: John (no_at_email)
Date: 03/07/05


Date: Mon, 07 Mar 2005 10:55:17 +0000

Mark Sizzler wrote:
> 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
>

JTable is a UI component. Trying to use it's DefaultTableModel to store
data as you are is ridiculous.

You should create a class based on a suitable data structure that also
implements TableModel.

You said "What a poor system architecture." I suggest that you learn how
to program before attempting to understand or criticise system architecture.

John



Relevant Pages

  • Re: Synchronizing the Main form and six (6) subforms?
    ... either just displaying the fields that relate the particular ShipType on the ... Am I to add this field to my one big table; and, how do I store ... >>> shipment to the correct main record. ...
    (microsoft.public.access.formscoding)
  • Re: combo box columns and key input
    ... Do not store the text along w/ the number in the table. ... The TextBox is an unbound control ... and if you hit 0 the ComboBox displayed None ... So you are displaying 0 - max num in the combo box ...
    (comp.databases.ms-access)
  • Saving AJAX responseText to a variable
    ... function ajaxObjectStateChange() ... retrieve, but it always come up as undefined (or a empty string if I ... I can never get the data to store in the variable. ... find on the web are the ones for immediately displaying the data. ...
    (comp.programming)
  • Re: Storing Database Result Field in a Variable.
    ... I have an ASP page that displays records from a SQL database, ... displaying all the records. ... not able to store the value to a variable. ... AND CostType = 'MT114')) AS Total, ...
    (microsoft.public.frontpage.programming)