默認(rèn)情況下,SWT的Table只會(huì)給整個(gè)Table設(shè)置Tooltip,要對(duì)每一個(gè)TableItem設(shè)置Tooltip的話,就要監(jiān)聽(tīng)鼠標(biāo)事件了:
????????table.addMouseTrackListener(new?MouseTrackAdapter()?{
????????????public?void?mouseHover(MouseEvent?event)?{
????????????????Point?pt?=?new?Point(event.x,?event.y);
????????????????int?index?=?table.getTopIndex();
????????????????while?(index?<?table.getItemCount())?{
????????????????????TableItem?item?=?table.getItem(index);
????????????????????for?(int?i?=?0;?i?<?table.getColumnCount();?i++)?{
????????????????????????Rectangle?rect?=?item.getBounds(i);
????????????????????????if?(rect.contains(pt))?{
????????????????????????????Object?object=?item.getData();
??????????????????????????? ........
????????????????????????}
????????????????????}
????????????????????index++;
????????????????}
????????????}
????????});
在省略號(hào)的地方就可以對(duì)對(duì)象進(jìn)行轉(zhuǎn)型了