Here you can find the source of copyCells(JTable table)
public static void copyCells(JTable table)
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.awt.Toolkit; import java.awt.datatransfer.StringSelection; import javax.swing.JTable; public class Main { public static void copyCells(JTable table) { StringBuffer sb = new StringBuffer(); int row = table.getSelectedRow(); for (int col : table.getSelectedColumns()) { sb.append(table.getValueAt(row, col)); sb.append("\t"); }/* ww w. ja v a 2 s . co m*/ final StringSelection stsel = new StringSelection(sb.toString()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stsel, stsel); } }