Re: Errors when deleting a row in a JTable.
From: Soren Kuula (dongfangREMOVE_at_bitplanet.net)
Date: 05/01/04
- Next message: Nick Landsberg: "Re: crash during file writing, how to recover ?"
- Previous message: Mok-Kong Shen: "Re: Cracking DES with C++ is faster than Java?"
- In reply to: Bernard Koninckx: "Re: Errors when deleting a row in a JTable."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 01 May 2004 15:25:19 +0200
Bernard Koninckx wrote:
> The code below return a good class object but I've already the same stack
> trace
> error
>
> public Class getColumnClass(int columnIndex) {
> Column colInfo = (Column)columns.get(columnIndex);
> String colName = colInfo.getColumnName();
> Field fieldInfo = findField(dataObjectClass, colName);
> Class className = fieldInfo.getType();
>
> return fieldInfo.getType();
> }
>
> I don't understand what's really the problem.
The problem IS your column classes. I can see that you sometimes return
Integer.TYPE, or TYPE of the wrapper class for some other simple type.
It does not work - JTable has no renderer installes for these types (I
am not even sure they are subtypes of Object). That's what you get
nullpointer exc.
Try this:
public Class getColumnClass(int columnIndex) {
Column colInfo = (Column)columns.get(columnIndex);
String colName = colInfo.getColumnName();
Field fieldInfo = findField(dataObjectClass, colName);
Class className = fieldInfo.getType();
if (className == Integer.TYPE)
return Object.class;
return fieldInfo.getType();
// if (getRowCount()>=1)
// return getValueAt(0,columnIndex).getClass();
// return null;
}
and it quits crashing.
That said, I think there is something overly complicated about your
table model. I't not worth all of your effort (reflection) to avoid
wrapper types in a TableModel, if that's what you want to do. If you
want to, a better way is still to have the getValueAt return a wrapper
type for underlying primitive types.
Also, avoid file name literals in your code. The code would not run here
until I had found and corrected them. And get rid o' them Vectors :)
Soren
- Next message: Nick Landsberg: "Re: crash during file writing, how to recover ?"
- Previous message: Mok-Kong Shen: "Re: Cracking DES with C++ is faster than Java?"
- In reply to: Bernard Koninckx: "Re: Errors when deleting a row in a JTable."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|