IntelliJ Java IDE
The moose likes Swing / AWT / SWT / JFace and the fly likes Expand hidden text in a JTable Cell Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Expand hidden text in a JTable Cell" Watch "Expand hidden text in a JTable Cell" New topic
Author

Expand hidden text in a JTable Cell

ram anantha
Greenhorn

Joined: Nov 29, 2000
Posts: 6
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

Joined: Oct 18, 2000
Posts: 4120

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


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
ram anantha
Greenhorn

Joined: Nov 29, 2000
Posts: 6
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

Joined: Oct 18, 2000
Posts: 4120

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

Joined: Nov 29, 2000
Posts: 6
Thanks a lot. That helped.
 
IntelliJ Java IDE
 
subject: Expand hidden text in a JTable Cell
 
Threads others viewed
How to delete and update sql table through JTable
problem with header text alignment
Extracting MS Word Table Cell as image
Get Cell Values from HTML Table Using Servlet
Wierd Behavior:TableCellRenderer
developer file tools