I have a JTable where the cells are not editable. How do I allow their contents to be selected and copied without making the Table editable?
Assuming that when you say copy you mean copy to the clipboard - you need to walk through all the selected cells, get the values for each cell, build a comma (or tab) separated list of values into a StringBuffer. Then copy that StringBuffer.toString() to clipboard using
: import java.awt.*; import java.awt.datatransfer.*; : : Toolkit tk = Toolkit.getDefaultTOolkit(); Clipboard sysCb = tk.getSystemClipboard(...); sysCb.setContent(new StringSelection(stringBuffer.toString()));