The only problem with that is it is very inefficient. With the tableModel, I'd have to loop through the rows AND columns.This is a task that has to be done everytime the table is referenced by the user - which is quite often - and it's a big table with a lot of columns, so a loop for this would cause severe lag.
I was hoping for a good utility.
If you want a deep clone,
you can either clone each of the instance variables inside the object
or try cloning using serialization provided all the objects implememnt Serializable
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
Object deepCopy = ois.readObject();
> Haven't tried it, but can't you put the same model
> into 2 tables?
no because i want to copy the tableModel. the table model is what contains my cell values. i want to keep a copy so that i can add and subtract rows from the tableModel, then if the user hits Cancel, use the copy to revert it.