jQuery in Action, 2nd edition*
The moose likes Swing / AWT / SWT and the fly likes Setting renderers on JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Setting renderers on JTable" Watch "Setting renderers on JTable" New topic
Author

Setting renderers on JTable

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
I have a JTable where I want one column to have multiline text in it.
I have a class called MultiLineCellRenderer, and then I have another
renderer class I created, to shade rows and set Fonts.
This is what I have done:

When I run my app, the column I want to be multiline is still just one
line of text. I do have a return in my data telling it to start a new line, so that isn't the problem.
How can I set the renderer for one column and then set the rest with another renderer?
Thanks for any help!
Jason Dobies
Greenhorn

Joined: Aug 13, 2003
Posts: 20
Have you tried simply creating a table with one column and assigning that the MultiLineCellRenderer? That'll help simplify whether the problem is in the renderer itself or in the way you were assigning the renderer to the column.


JCP, JCD, WCD... and all around nice guy.
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
I took out the line of code that was setting the default renderer and
left the line of code setting the cell renderer for the column that needs to have multiline cells, and it is still not working.
However, I tried setting the defaultTableRenderer to the MultiLineCellRenderer and then it worked??
Why doesn't it work when I set it to just one column? Am I setting it correctly? The problem doesn't seem to be in the renderer.
Any ideas?
Here's the renderer extending JTextArea:

Thanks again!
[ August 19, 2003: Message edited by: Jennifer Sohl ]
[ August 19, 2003: Message edited by: Jennifer Sohl ]
Mohamed Iqzas
Ranch Hand

Joined: Jan 02, 2012
Posts: 59



first you set the renderer for your specific column(index:8), and then for the entire table... I you're overriding the multi line renderer with StockAvailRenderer.

First the renderer of the table - StockAvailRenderer shud be set and then for the specific column. It might work. BTW not going to help after 10 years and 2days.. ;)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting renderers on JTable