예제 #1
0
 public String getClipboardContents() {
   Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
   if (contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
     try {
       return (String) contents.getTransferData(DataFlavor.stringFlavor);
     } catch (Exception e) {
       return "";
     }
   }
   return "";
 }
예제 #2
0
 public void copySelection() {
   Toolkit.getDefaultToolkit()
       .getSystemClipboard()
       .setContents(new StringSelection(getSelectedText()), this);
 }