private void paste() {
int startRow = (insertRecordTableUI.getSelectedRows())[0];
int startCol = (insertRecordTableUI.getSelectedColumns())[0];
try {
String trstring = (String) (clipBoard.getContents(this).getTransferData(DataFlavor.stringFlavor));
StringTokenizer st1 = new StringTokenizer(trstring, "\n");
for (int i = 0; st1.hasMoreTokens(); i++) {
int rowIdx = startRow + i;
String rowstring = st1.nextToken();
StringTokenizer st2 = new StringTokenizer(rowstring, "\t");
for (int j = 0; st2.hasMoreTokens(); j++) {
int colIdx = startCol + j;
String value = st2.nextToken();
if (colIdx < insertRecordTableUI.getColumnCount()) {
// If more data is pasted than currently rows exists
// empty rows are added to take the additional data
if (rowIdx >= insertRecordTableUI.getRowCount()) {
insertRecordTableUI.appendEmptyRow();
}
insertRecordTableUI.setValueAt(value, rowIdx, colIdx);
}
}
}
} catch (UnsupportedFlavorException | IOException | RuntimeException ex) {
LOG.log(Level.INFO, "Failed to paste the contents ", ex);
}
}
InsertRecordDialog.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:incubator-netbeans
作者:
评论列表
文章目录