• Post Reply Bookmark Topic Watch Topic
  • New Topic

Expand hidden text in a JTable Cell  RSS feed

 
ram anantha
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Lets say I have a table. One of the columns of the table is short enough that the text of all the cells in that column are not fully visible. If I move my mouse to any of these cells, I would like to see the full text displayed (similar to the way the tool tip text display behavior). How can I do this?
Thanks.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you just answered your own question.... extend the table's DefaultCellRenderer to add a tool tip to the component...

Here's a quick example... you may want to look for a multi-line tooltip implementation (there are probably some on JavaRanch, and there are definitely some floating out there on the 'Net...) since your lines of text will be pretty long...



-Nate
 
ram anantha
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response. That was helpful. The default tool tip location is to the right and bottom. How can I change the position of the tool tip location? I tried overriding the setToolTipLocation(Point p) method in the cell renderer but that doesn't work. Thanks.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to override the method :


in your JTable... for some reason, changing it in the TableCellRenderer doesn't affect how the tooltip location is figured out...

-Nate
 
ram anantha
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot. That helped.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!