Tooltip in other colums with Java SWT?

陌路散爱 提交于 2019-12-04 18:45:11

Your problem is this line:

Rectangle rect = item.getBounds(0);

You are asking for the bounds of the first column. Just change the index to the column where you want your tooltip to appear and you'll be fine:

Rectangle rect = item.getBounds(2);

If you need to get the column index from the mouse position, use this code:

Point point = new Point(event.x, event.y);
int column = 0;
for (int i = 0; i < table.getColumnCount(); i++)
{
    if (item.getBounds(i).contains(point))
    {
        column = i;
        break;
    }
}

Rectangle rect = item.getBounds(column);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!