I have a program in which I want to use drag and drop. I went through the java drag and drop documentation but I could not really find an answer for this. I want to use the TransferHandler. Basically what I am trying to do is transfer the whole JTextField not only the text inside it so it retains all of it properties. Or in other words the whole object. I saw that you can do a custom DataFlavor.
DataFlavor customFlavor = new DataFlavor(JTextField.class, "JTextField");
I would than probably import data like this:
importData(TransferHandler.TransferSupport supp){
Transferable t = supp.getTransferable();
JTextField data = t.getTransferData(customFlavor);
}
The problem I have is how to send the data so I can read it. I am thinking of something like this.
Transferable createTransferable(JComponent c) {
return new JTextField(); ???
}
How should I transform this to be able to send the JTextField and reconstruct it after the drop.