multiline renderer


2004-07-20 02:46:17 PM
jbuilder0
How does one get multiline cells in a jdbtable (not a jtable)? Google
finds partial answers, many of them quite old, or they are not for a
jdbtable (with its query dataset which defines the columns). From those
partial answers I have been able to have some success, but not complete
success. A working example would show me where I'm off.
If the answer isn't obvious to someone reading my comments, I can post
my code. If I do that, I guess I'd like some feedback on which of the
three approaches I tried I should post.
As I said, I have tried several approaches but none works or works quite
right.
First attempt, I wrote a cell renderer and made it the default.
myTable.setDefaultRenderer(Object.class, new myMultiLineCellRenderer());
Setting the default renderer does nothing. The constructor is called,
but that's it.
Second attempt:
Use the same renderer as an item painter for each column in the query
dataset, like this:
columns[columnx].setItemPainter(new ZZ_MultiLineCellRenderer());
(Notice that this is some generic code and my columns are in an array,
hence columns[columnx] instead of column1 or whatever.)
This works, but it's called repeatedly (as indicated by debugging
output). The cpu is pegged at 100%.
Third attempt:
I tried a columnpaintlistener, as suggested in the jbuilder info on
"Jdbtable Class". I wrote a simple columnpaintlistener and it could
change the color of the cells in the table, but I don't see any way to
change the value of the text to be multiline.
I'm learning various things about jbuilder and dbswing, but haven't
struck gold yet.
Thanks
John