If I read you correctly, your table will not be able to guarantee that all fields under a single column will be of the same type. This complicates things.
What you'd need to do is create a custom CellEditor for your JTable. The CellEditor's job is to return a Component for the specified column and row in the table. This Component is what is used to edit the value stored in the cell.
This Component could be a JTextField or whatever you want, so yes, it would support insertString() if it were the correct Component.
There is a DefaultCellEditor in javax.swing, so you may not have to implement the full interface.
It's the same for viewing cells: a JTable has a CellRenderer. I don't understand what you're trying to do with cell hiding, but I assume you're just trying to make them look like solid blocks or something. (If you're trying to hide the entire column it would be easier.) You can make cells look like anything you want.
Originally posted by Sayuri Coppinger:
I am creating a table that contains cells with different data types (text, double, integer, formatted double etc). The user can input values into these cells, and I need to come up with a way to determine if the input is correct. With textfields, I can customize the document, so it would only allow numbers or alpha values when the user tries to enter them, but how do I deal with this in a table. I know I need to create a cell model for each type since these types could be in any column/row. Is there another way to handle this problem, and can the cell model do something similar to the insertString method in the document object?
Also, some cells need to be created but the user does not want to see them since they are readonly. Aside from changing the background color, is there another to make these cells hidden?
I would really appreciate any ideas/input on this!
Thanks