Here you can find the source of copyRows(JTable table)
public static void copyRows(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 copyRows(JTable table) { StringBuffer sb = new StringBuffer(); for (int iSelectedRow : table.getSelectedRows()) { sb.append(getColumnData(table, iSelectedRow)); sb.append("\n"); }// w w w. j a v a2 s . c om final StringSelection stsel = new StringSelection(sb.toString()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stsel, stsel); } private static StringBuffer getColumnData(final JTable table, final int iSelectedRow) { final int iColumnCount = table.getColumnCount(); final StringBuffer sb = new StringBuffer(); for (int iColumn = 0; iColumn < iColumnCount; iColumn++) { sb.append(table.getValueAt(iSelectedRow, iColumn)); sb.append("\t"); } return sb; } }