new javax.swing.JTable()
{
public String getToolTipText(java.awt.event.MouseEvent e) {
String tip = null;
java.awt.Point p = e.getPoint();
int rowIndex = rowAtPoint(p);
int colIndex = columnAtPoint(p);
int realColumnIndex = convertColumnIndexToModel(colIndex);
if (realColumnIndex == 6) { // comment column
tip = (String) getValueAt(rowIndex, colIndex);
}
int numberOfLines = 0;
String newTip = "";
//If tip is shorter than 50 chars add a new line leave on one line
if (tip.length() > 50) {
numberOfLines = (int) (tip.length() / 50);
//numberOfLines will most likely not be a whole number so add 1 just in case
numberOfLines += 1;
for (int i = 0; i < numberOfLines; i++) {
if (tip.length() > 50) {
//tip is greater then 50 add a new line. also check to ensure the remaining tip is atleast 50 chars long
newTip += tip.substring(0, 50) + " \n";
tip = tip.substring(50, tip.length());
} else {
//the remaining tip is not 50 chars long just add the remainder to new tip
newTip += tip.substring(0, tip.length());
}
}
} else {
newTip = tip;
}
System.out.println("newTip in the new code is = "+ newTip);
return newTip;
}
}