Reputation: 2148
When I use getTransferData(DataFlavor.stringFlavor) to paste some text from clipboard like:
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
String text=null;
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
text= (String) t.getTransferData(DataFlavor.stringFlavor);
}
I get exception javax.swing.text.BadLocationException: Invalid location. Why does this happen ?
Upvotes: 1
Views: 595
Reputation: 12484
attempts to reference a location that doesn't exist.
So you'll have to double-check in the GUI code.
But this appears to be an error within the Swing part, not because of getTransferData(DataFlavor.stringFlavor)
itself
Upvotes: 1