public void copyCells() {
StringBuffer sbf = new StringBuffer();
// Check to ensure we have selected only a contiguous block of
// cells
int numcols = getSelectedColumnCount();
int numrows = getSelectedRowCount();
int[] rowsselected = getSelectedRows();
int[] colsselected = getSelectedColumns();
if (!((numrows - 1 == rowsselected[rowsselected.length - 1] - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1]
- colsselected[0] && numcols == colsselected.length))) {
JOptionPane.showMessageDialog(null, "Invalid Copy Selection", "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE);
return;
}
for (int i = 0; i < numrows; i++) {
for (int j = 0; j < numcols; j++) {
sbf.append(getValueAt(rowsselected[i], colsselected[j]));
if (j < numcols - 1) {
sbf.append("\t");
}
}
sbf.append("\n");
}
stsel = new StringSelection(sbf.toString()) {
@Override
public void lostOwnership(Clipboard clipboard, Transferable contents) {
canPaste = false;
}
};
clip.setContents(stsel, stsel);
canPaste = true;
}
ExactTable.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:jmt
作者:
评论列表
文章目录