I have a JTable where one column occasionally has a fair amount of text in it. There are algorithms that we're using to expand the height of each row to the tallest cell. The problem is for long text cells we get "fat" rows.
It looks something like this:
============================= | Col1 | Col2 | This is some| | | | very long | | | | text! | =============================
I've considered a couple solutions:
Does anyone know of any libraries that fix this? I'm open to using some other technique...I'm not convinced my solution is the best.
Thanks in advance!
I would just use a tooltip.
You can override the getToolTipText(() method of JTable to do this.
JTable table = new JTable(...)
{
public String getToolTipText( MouseEvent e )
{
int row = rowAtPoint( e.getPoint() );
int column = columnAtPoint( e.getPoint() );
Object value = getValueAt(row, column);
return value == null ? null : value.toString();
}
};
Or if its only for certain columns you can use the renderer to set the tooltip text. See Specifying Tool Tips for Cells.