in Advanced 

Question preview

HomeQuestion preview:
Log in

I want to display html tooltip for cell in JTable

Is it possible to display html tooltip from cell in JTable? What should I implement to achieve this.
Do you know someone who could answer? Ask him for help
Answers: 1
Sort by: date rating
image xpert
12:39/02.01.2008
2.1 from possible 5 with 11 votes
In JTable there is method:
public String getToolTipText(MouseEvent event) {
...
}

which uses tooltip from your renderer component. You can implement getToolTipText for your renderer component:
public String getToolTipText(MouseEvent event) {
 //your implementation goes here
}


If you use DefaultTableCellRenderer you can just set the tooltip directly in the method getTableCellRendererComponent:
public Component getTableCellRendererComponent(JTable table, Object value,
                          boolean isSelected, boolean hasFocus, int row, int column) {
    setToolTipText("<html>Tooltip at <b>cell</b> " + row + ", " + column + "</html>");
    return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

}


In order tooltip to be rendered as html you should include <html> in the beginning and </html> at the end of tooltip but you can use only very limited features of HTML in the tooltip.
Vote:
Please vote! Your opinion matters!
If you haven't found what you've looking for, post a question
Ask question
| Home | Hall of fame | Registration | Log in | Terms of service | Privacy policy | Help | Contacts | RSS |