Java JTable Cell copyCells(JTable table)

Here you can find the source of copyCells(JTable table)

Description

copy Cells

License

Open Source License

Declaration

public static void copyCells(JTable table) 

Method Source Code

//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);
    }
}

Related

  1. addComboCell(TableColumn column, Object[] items)
  2. defaultTableCellSize()
  3. getCellBounds(JTable table, int top, int bottom)
  4. getCellRectangle(JTable table, int row, int column)
  5. getColumnNames(JTable table, String lineBreak, String cellBreak)