Skip to content

Instantly share code, notes, and snippets.

@Aroueterra
Created February 8, 2020 03:32
Show Gist options
  • Save Aroueterra/e71a243605fe060a1c9a8205bb9fc613 to your computer and use it in GitHub Desktop.
Save Aroueterra/e71a243605fe060a1c9a8205bb9fc613 to your computer and use it in GitHub Desktop.
private void simulateClipBoard() {
javax.swing.table.DefaultTableModel model = (javax.swing.table.DefaultTableModel) table_RenamingInputOutput.getModel();
int np = model.findColumn("[Name]");
if (table_RenamingInputOutput.getSelectedColumn() == np) {
try {
String data = (String) Toolkit.getDefaultToolkit()
.getSystemClipboard().getData(DataFlavor.stringFlavor);
String[] values = data.split("[\\r\\n]+");
if (values.length > 1) {
for (int i = table_RenamingInputOutput.getSelectedRow(), j = 0; i <= table_RenamingInputOutput.getRowCount() - 1 && j <= values.length-1; i++, j++) {
if (values[j] != null) {
table_RenamingInputOutput.setValueAt(values[j], i, np);
}
}
}
} catch (UnsupportedFlavorException ex) {
Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment