OK, I'm stumped.
I have a JTable. In the model, I have two columns. The first is an object and the table uses it's toString() method to determine what it displays. The second is another object and that works similarly.
When the user presses a button, I want to retrieve the object in the first column and make some changes to it. What I change depends on whether one row is selected or multiple.
When the table has only a single row selected, this works perfectly. However, if multiple rows are selected, calling getValueAt(n,0) returns the
String from the object's toString() rather than the object itself. Can somebody explain this to me? My code is below. I am using NetBeans 6.8 on 64-bit
Java 6 on a Mac.
When one row selected:
When multiple rows are selected:
In the first case, t is an instance of Territory. In the second, t is an instance of String and a ClassCastException is thrown.