Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting renderers on JTable

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.. ;)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic