Originally posted by Lars Tode:
Hi,
i've an idea but i'm not really sure.
May b java can't convert the vectors value 4 the table?
Is it true that a vector is an (kind of) dynamic array?
Mean that it has some kind of index like an array.
I've also another question, what i've heard Vectors are like pointers (c++), so what happen when i'm doing something like this :
String text = new String("Hello world");
Vector test = new Vector();
test.insertElementAt(text,test.size());
text = "";
Is the Vector now point at a null-value?
greetx
Lars
I'm going to try to answer both of your questions.
About the table, I noticed in your addRow(..) method all you do is add the element to the Vector. Just because the JTable is displaying the Vector and you change the Vector then call repaint() doesn't mean that the JTable will get a fresh version of the Vector to render. The way that I would handle this situation would be: create the table, when you need to add something to both the Vector and the table then; add it to the Vector and use
setValueAt(Object aValue, int row, int column) to update the table.
On to the whole Vector situation
Think about what has been added to the Vector,
text, that is a reference to an Object. So if you change the Object that it points to then when you retrieve the reference from the Vector then it will point to the modified Object.
Hope this helps.
[ April 18, 2002: Message edited by: Ibrahim Hashimi ]