用动作去驱动未来

生命在于运动,让自己身体的每一个细胞都动起来吧.

 

(按Ctrl+C)选中的table表单中的数据,粘贴(按Ctrl+V)到目标文件(Excel,Word...)

希望这个方法能帮助到你:
 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     }

posted on 2012-11-07 10:11 黑蚂蚁 阅读(1144) 评论(0)  编辑  收藏 所属分类: SWT,JFACE


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

公告

路在脚下,此刻,出发。

常用链接

留言簿

随笔分类

随笔档案

文章分类

文章档案

相册

搜索

最新评论

阅读排行榜

评论排行榜