List of usage examples for java.awt.datatransfer FlavorListener FlavorListener
FlavorListener
From source file:Main.java
public Main() { // Implement Copy operation StringSelection contents = new StringSelection("data"); clipboard.setContents(contents, this); FlavorListener lis = new FlavorListener() { @Override/* ww w .j ava2 s. co m*/ public void flavorsChanged(FlavorEvent e) { System.out.println(e); } }; clipboard.addFlavorListener(lis); clipboard.removeFlavorListener(lis); // Implement Paste operation Transferable content = clipboard.getContents(this); String dstData; try { dstData = (String) content.getTransferData(DataFlavor.stringFlavor); System.out.println(dstData); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public Main() { // Implement Copy operation StringSelection contents = new StringSelection("data"); clipboard.setContents(contents, this); FlavorListener lis = new FlavorListener() { @Override//from ww w. j av a2 s . co m public void flavorsChanged(FlavorEvent e) { System.out.println(e); } }; clipboard.addFlavorListener(lis); FlavorListener[] flavors = clipboard.getFlavorListeners(); for (FlavorListener f : flavors) { System.out.println(f); } // Implement Paste operation Transferable content = clipboard.getContents(this); String dstData; try { dstData = (String) content.getTransferData(DataFlavor.stringFlavor); System.out.println(dstData); } catch (Exception e) { e.printStackTrace(); } }
From source file:ja.lingo.application.gui.actions.PasteAndTranslateAction.java
public PasteAndTranslateAction(Model model) { this.model = model; Toolkit.getDefaultToolkit().getSystemClipboard().addFlavorListener(new FlavorListener() { public void flavorsChanged(FlavorEvent e) { setEnabled(((Clipboard) e.getSource()).isDataFlavorAvailable(DataFlavor.stringFlavor)); }/*from ww w .j a va2 s.c om*/ }); }