Table tableItem tooltips

默认情况下,SWT的Table只会给整个Table设置Tooltip,要对每一个TableItem设置Tooltip的话,就要监听鼠标事件了:


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++; 
          } 
      } 
  }); 

参考:http://dearwolf.iteye.com/blog/40869

你可能感兴趣的:(tooltip)