因此,我阅读了几个有工具提示工作的线程,并试图解决这个问题无济于事。我不知道如何让我的工具提示工作
import 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中的任何位置显示一个提示数组拉弦。所有的帮助表示赞赏。 :)
我还需要工具提示横跨整个行。 但这仍然没有关系,因为我无法让工具提示出现在任何地方。
参见[*指定工具提示细胞*](HTTP://文档.oracle.com/JavaSE的/教程/ uiswing /组件/ table.html#celltooltip)。 – trashgod
您是否尝试过使用setToolTipText方法? –
我不是这样做的。我很新的这个jtable的东西 – Jest