title: Drag and drop between two Jtables
body: <p>So I managed to make Jtable working one way, from table1 to table2. but I don't really know how to make it work both ways(from table2 to table1). I was trying putting transferhandler on both Jtables, but I guess that they interfere with each other. So I'm pretty much stuck. Can someone explain how should I do it?
  Here is the implementation (when I'm trying to do the same with the second Jtable it is not working):</p>
  
  <pre><code>table1.setDragEnabled(true);
  table2.setTransferHandler(new TransferHandler() {
              public boolean canImport(TransferSupport support) {
                  if (!support.isDrop()) {
                      return false;
                  }
  
                  if (!support.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                      return false;
                  }
                  return true;
              }
  
              public boolean importData(TransferSupport support) {
                  if (!canImport(support)) {
                      return false;
                  }
                  int row2 = table1.getSelectedRow();
                  int rows[] = table1.getSelectedRows();
                  if (rows.length &gt; 1){
                      Object strings2[][] = new String[rows.length][2];
                      for (int i=0; i&lt;rows.length; i++) {
                          for (int j = 0; j &lt; 2; j++)
                              strings2[i][j] = table1.getValueAt(rows[i], j);
                      }
                      String pathToCopy, pathToPaste;
                      for (int k=0; k&lt;strings2.length; k++) {
                          if (path.equals("C:\\"))
                              pathToCopy = text1.getText() + trimmer(strings2[k][0].toString());
                          else
                              pathToCopy = text1.getText() + "\\" + trimmer(strings2[k][0].toString());
                          if (path2.equals("C:\\"))
                              pathToPaste = path2 + trimmer(strings2[k][0].toString());
                          else
                              pathToPaste = text2.getText() + "\\" + trimmer(strings2[k][0].toString());
                          File toCopy = new File(pathToCopy);
                          File toPaste = new File(pathToPaste);
                          try {
                              copyPaste(toCopy, toPaste);
                          } catch (IOException e) {
                              System.out.println("Nie można skopiować pliku!");
                          }
                      }
                      return true;
                  }
                  else {
                      if (row2 != -1) {
                          for (int i = 0; i &lt; 2; i++)
                              strings[i] = table1.getValueAt(row2, i);
                      }
                      String pathToCopy, pathToPaste;
                      if (path.equals("C:\\"))
                          pathToCopy = text1.getText() + trimmer(strings[0].toString());
                      else
                          pathToCopy = text1.getText() + "\\" + trimmer(strings[0].toString());
                      if (path2.equals("C:\\"))
                          pathToPaste = path2 + trimmer(strings[0].toString());
                      else
                          pathToPaste = text2.getText() + "\\" + trimmer(strings[0].toString());
                      File toCopy = new File(pathToCopy);
                      File toPaste = new File(pathToPaste);
                      try {
                          copyPaste(toCopy, toPaste);
                      } catch (IOException e) {
                          System.out.println("Nie można skopiować pliku!");
                      }
                      return true;
                  }
              }
          }); 
  </code></pre>