I used to face the same problem, and that’s how I solved it:
First you have to make table SWT.FULL_SELECTION`;
Then you should get the selected cell by reading the mouse position (because the base table swt does not provide listeners to select the selected cell, select an item, maybe). Here is the code:
table.addListener(SWT.MouseDown, new Listener(){ public void handleEvent(Event event){ Point pt = new Point(event.x, event.y); TableItem item = table.getItem(pt); if(item != null) { for (int col = 0; col < table.getColumnCount(); col++) { Rectangle rect = item.getBounds(col); if (rect.contains(pt)) { System.out.println("item clicked."); System.out.println("column is " + col); } } } } });
cindy source share