• 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

Expand hidden text in a JTable Cell

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot. That helped.
 
reply
    Bookmark Topic Watch Topic
  • New Topic