Re: Funky problem with JTable cell rendering
From: Jan Danielsson (jan.danielsson_at_gmail.com)
Date: 12/31/04
- Previous message: Jim McMaster: "Swing vs. SWT"
- Next in thread: Christian Kaufhold: "Re: Funky problem with JTable cell rendering"
- Reply: Christian Kaufhold: "Re: Funky problem with JTable cell rendering"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 31 Dec 2004 23:56:36 +0100
Christian Kaufhold wrote:
>>At this point, I expect to get the most common answer: "You need to
>>implement getColumClass() in your table model".
>>
>>I already did that, look:
>>-------
>> public Class getColumClass(int col) {
>> System.out.println("Returning: " + getValueAt(0, col).getClass());
>> return getValueAt(0, col).getClass();
>> }
>>-------
>
>
> The method to override is called "getColumnClass".
Wadd'ya know! :-) Thanks!
Makes me wonder: I wonder if those other having the same problem as I
had copied code from the same webpage as I did?
> Your implementation is wrong in some places:
> 1. It will fail with an exception if the TableModel happens to have
> zero rows at one time.
How come? When does getColumnClass() get called, other than when there
are rows?
> 2. It will give wrong results if the class of the element in the
> first row is not the same or a superclass of the elements in the
> other rows, e.g. if the first row contains a String, but the other
> rows don't all also contain Strings, but other objects.
This limitation I am aware of, but since the colums are directly mapped
to columns in an SQL database, that doesn't matter.
Thanks for spotting that typo..
- Previous message: Jim McMaster: "Swing vs. SWT"
- Next in thread: Christian Kaufhold: "Re: Funky problem with JTable cell rendering"
- Reply: Christian Kaufhold: "Re: Funky problem with JTable cell rendering"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|