• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting renderers on JTable

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 77
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.. ;)
reply
    Bookmark Topic Watch Topic
  • New Topic