Search in sources :

Example 91 with StringSelection

use of java.awt.datatransfer.StringSelection in project beast-mcmc by beast-dev.

the class TempestFrame method doCopy.

@Override
public void doCopy() {
    StringWriter writer = new StringWriter();
    PrintWriter pwriter = new PrintWriter(writer);
    for (String tip : tempestPanel.getSelectedTips()) {
        pwriter.println(tip);
    }
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    StringSelection selection = new StringSelection(writer.toString());
    clipboard.setContents(selection, selection);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 92 with StringSelection

use of java.awt.datatransfer.StringSelection in project processdash by dtuma.

the class ClipboardHelper method writeContents.

@Override
protected void writeContents() throws IOException {
    String id = getParameter("id");
    Integer i = Integer.parseInt(id);
    String clip = CLIP_ITEMS.get(i);
    if (clip != null) {
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(clip), null);
    } else {
        Toolkit.getDefaultToolkit().beep();
    }
    DashController.printNullDocument(out);
}
Also used : StringSelection(java.awt.datatransfer.StringSelection)

Aggregations

StringSelection (java.awt.datatransfer.StringSelection)92 Clipboard (java.awt.datatransfer.Clipboard)23 ActionEvent (java.awt.event.ActionEvent)11 Transferable (java.awt.datatransfer.Transferable)7 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 JPanel (javax.swing.JPanel)6 JTextArea (javax.swing.JTextArea)6 ActionListener (java.awt.event.ActionListener)5 Editor (com.intellij.openapi.editor.Editor)4 Project (com.intellij.openapi.project.Project)4 PsiFile (com.intellij.psi.PsiFile)4 ClipboardOwner (java.awt.datatransfer.ClipboardOwner)4 JMenuItem (javax.swing.JMenuItem)4 JScrollPane (javax.swing.JScrollPane)4 BibEntry (org.jabref.model.entry.BibEntry)4 AnAction (com.intellij.openapi.actionSystem.AnAction)3 PsiElement (com.intellij.psi.PsiElement)3 BorderLayout (java.awt.BorderLayout)3