• Identifying text truncation in JTable cells

    From herphan@gmail.com@21:1/5 to All on Tue Jun 21 23:35:13 2016
    Thanks for the hints on how to do this. I elaborated a little on it trying to get rid of the TableColumn. I aldready had a subclass of DefaultTableCellRenderer doing some custom coloring in getTableCellRendererComponent(). I could extend this method for
    doing the tooltip stuff - see this stripped down version:

    public class TableCellRendererMy extends DefaultTableCellRenderer implements TableCellRenderer {

    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

    double cellPrefWidth = getPreferredSize().getWidth();
    double cellWidth= table.getCellRect(row, column, false).getWidth();

    if (cellPrefWidth>cellWidth) {
    try {
    setToolTipText(String.valueOf(value));
    } catch (Exception e) {
    }
    }

    return this;
    }
    }

    regerds,
    stephan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)