希望这个方法能帮助到你:
1 public static void addCopyListener(final Table table) {
2 table.addKeyListener(new KeyAdapter() {
3 public void keyPressed(KeyEvent e) {
4 if (e.stateMask == SWT.CTRL && e.keyCode == 'c') {
5 Clipboard board = new Clipboard(Display.getDefault());
6 TableItem[] item = table.getSelection();
7 TableColumn[] tc = table.getColumns();
8
9 String copyStr = "";
10 for (int i = 0; i < item.length; i++) {
11 for (int j = 0; j < tc.length; j++) {
12 copyStr += item[i].getText(j) + "\t";
13 }
14 copyStr = copyStr + "\n";
15 }
16 if (!"".equals(copyStr)) {
17 board.setContents(new String[] { copyStr }, new Transfer[] { TextTransfer.getInstance() });
18 }
19 }
20 }
21 });
22 }