Tooltip for components located in TableCellRenderer component

how can I add ToolTips for each components located in TableCellRenderer component?

In bellow example I took panel as TableCellRenderer component. I put two labels in it. I need diffrent tooltips for two labels.

import java.util.*;

import java.awt.*;

import javax.swing.*;

import javax.swing.table.*;

import java.awt.event.*;

/**

*

* @author kesava

*/

public class TooltipForTableCell extends JFrame {

JTable table;

DefaultTableModel tableModel;

/**

* Creates a new instance of TooltipForTableCell

*/

public TooltipForTableCell() {

init();

setDefaultCloseOperation(EXIT_ON_CLOSE);

pack();

setVisible(true);

}

public void init() {

Vector<String> columns = new Vector<String>();

columns.add("col-1");

columns.add("col-2");

Vector<Vector><String>> data = new Vector<Vector><String>>();

Vector<String> row = new Vector<String>();

row.add("aaa-1");

row.add("bbb-1");

data.add(row);

row = new Vector<String>();

row.add("aaa-2");

row.add("bbb-2");

data.add(row);

tableModel = new DefaultTableModel(data, columns);

table = new JTable(tableModel) {

public int getRowHeight() {

return 25;

}

};

table.getColumn("col-1").setCellRenderer(new CustomTableCellRenderer());

table.getColumn("col-2").setCellRenderer(new CustomTableCellRenderer());

getContentPane().add(new JScrollPane(table));

}

public class CustomTableCellRenderer extends JPanel implements TableCellRenderer {

String pos;

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

pos = "(" + row + "," + column + ")";

JLabel label1 = new JLabel(value.toString());

JLabel label2 = new JLabel(pos);

removeAll();

add(label1);

add(label2);

return this;

}

}

public static void main(String[] args){

new TooltipForTableCell();

}

}

[2195 byte] By [gkesavareddy@yahoo.coma] at [2007-11-27 3:56:40]
# 1
have a look to: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#celltooltip
suparenoa at 2007-7-12 9:00:54 > top of Java-index,Desktop,Core GUI APIs...
# 2
Supareno, It will help to put a tooltip for a cell.But I need two diffrent tooltips for two labels which are in one cell.
gkesavareddy@yahoo.coma at 2007-7-12 9:00:54 > top of Java-index,Desktop,Core GUI APIs...
# 3
> Supareno, It will help to put a tooltip for a cell.> > But I need two diffrent tooltips for two labels which> are in one cell.good luck!
suparenoa at 2007-7-12 9:00:54 > top of Java-index,Desktop,Core GUI APIs...