所以我阅读了一些有工具提示工作的线程,并试图解决它无济于事。
导入 java.awt.event.MouseEvent;
public String getToolTipText(MouseEvent e) {
String tip = "tommy likes trucks";
java.awt.Point p = e.getPoint();
int rowIndex = FursJTable.rowAtPoint(p);
int colIndex = FursJTable.columnAtPoint(p);
int realColumnIndex = FursJTable.convertColumnIndexToModel(colIndex);
//if (description[realColumnIndex] = null || description[realColumnIndex] = "") {
// tip = null;
//} else {
// tip = description[realColumnIndex];
//}
return tip;
}
if 语句应该只从我将设置的数组中提取一个字符串,但即使我只是在代码的开头设置了提示,它也不会在我的 jtable 中的任何地方显示工具提示。感谢所有帮助。:)
我还需要工具提示横跨整行。但这仍然无关紧要,因为我无法让工具提示出现在任何地方。