Babu Kalakrishnan wrote:
> Rogan Dawes wrote:
>
>> Babu Kalakrishnan wrote:
>
>
>>>
>>> Unfortunately a renderer cannot scroll (since it will not receive any
>>> events) - so i'd guess it will have to be an editor only.
>>>
>>> BK
>>
>>
>>
>> You could follow the approach used by JTreeTable, and make the cell
>> always return true for isEditing() (or something along those lines)
>>
>> i.e. how JTreeTable gets the JTree to open and close . . .
>>
>
> Are you referring to the JTreeTable class that appeared in the "The
> Swing Connection" articles ?
>
> With all due respects to the stalwarts who created the example class/es
> (Quite a bit of what I've learnt about the Swing library have been from
> following their articles), I've always felt that its design was
> something of a hack. Everything in its design "improvements" being some
> kind of a workaround to what a JTable is inherently incapable of doing.
>
> Haven't followed the progress of this in the past year or so since I was
> too busy in other areas of the technology. But unless something has
> drastically changed (which I doubt), renderers are still what they were:
> transient beings that paint a cell and then disappear - what you see on
> screen is only an image of what they painted a while back - the user
> cannot interact with them - period.
>
> BK
Sure, it seems like a hack to me, too. I don't think that there have
been any adjustments to the source in the last couple of years, at least.
Effectively, what I see as the key "trick" here is this snippet from
AbstractTreeTableModel.java (possibly resulting from some hackery of my
own, but still):
/** By default, make the column with the Tree in it the only
editable one.
* Making this column editable causes the JTable to forward mouse
* and keyboard events in the Tree column to the underlying JTree.
*/
public boolean isCellEditable(Object node, int column) {
return getColumnClass(column) == TreeTableModel.class;
}
Which effectively makes the TreeTable use an editor all the time, I
think, rather than a renderer.
Rogan
|