I have some problems displaying data in JTable. My app is using a JTable and a custom AbstractTableModel. In my AbstractTableModel I have a private field SomeClass[] array and that class is something like:
public char[] field1;
public char[] field2;
etc.
Also in my AbstractTableModel I have override getValueAt method and it contains something like this:
...
switch(column){
case(0):
retrun array[row].field1;
case(1):
return array[row].field2;
}
etc.
When I do a System.out.println(array[row].field1) the data is displayed correctly, but in my jTable is something like “[C@203 ………”.
What is the problem? :-s How can i fix this? Can anyone help me?
The default renderer for a JTable simply invokes the toString() method on the Object that is returned from the getValueAt(…) method.
field1 is a char array. The toString() representation of the array is the wierd text that you see.
You should not be storing a char array in the model to represent the data of a cell. Instead create and store an actual String in the model.