Example usage for java.awt Toolkit getSystemClipboard

List of usage examples for java.awt Toolkit getSystemClipboard

Introduction

In this page you can find the example usage for java.awt Toolkit getSystemClipboard.

Prototype

public abstract Clipboard getSystemClipboard() throws HeadlessException;

Source Link

Document

Gets the singleton instance of the system Clipboard which interfaces with clipboard facilities provided by the native platform.

Usage

From source file:Main.java

public static void main(String[] args) {
    Toolkit tk = Toolkit.getDefaultToolkit();

    System.out.println("System clipboard = " + tk.getSystemClipboard());

}

From source file:UploadUtils.ImgurUpload.java

/**
 * Copy image link to user's clipboard.//w  w  w.j  ava2s . c  o m
 * This method could be called in onImageLink(String link) to copy the link to the user's clipboard.
 * @param imgurl the string to copy to the clipboard
 */
public static void copyToClipBoard(String imgurl) {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Clipboard clipboard = toolkit.getSystemClipboard();
    StringSelection selection = new StringSelection(imgurl);
    clipboard.setContents(selection, null);
}

From source file:UploadUtils.PomfUpload.java

/**
 * Copy image link to user's clipboard.//from   ww w .  j  a  va 2s. co m
 * This method could be called in onImageLink(String link) to copy the link to the user's clipboard.
 * @param link the string to copy to the clipboard
 */
public static void copyToClipBoard(String link) {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Clipboard clipboard = toolkit.getSystemClipboard();
    StringSelection selection = new StringSelection(link);
    clipboard.setContents(selection, null);
}

From source file:screenieup.ImgurUpload.java

/**
 * Copy image link to user's clipboard./* w w w  .ja  v  a  2 s .  c  om*/
 */
private void copyToClipBoard() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Clipboard clipboard = toolkit.getSystemClipboard();
    StringSelection selection = new StringSelection(imgurl);
    clipboard.setContents(selection, null);
    System.out.println("Image URL copied to clipboard.");
}

From source file:screenieup.MixtapeUpload.java

/**
 * Copy upload link to clipboard.//  w w  w  .j  a  va 2  s.  c  o  m
 */
public void copyToClipBoard(String string) {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Clipboard clipboard = toolkit.getSystemClipboard();
    StringSelection selection = new StringSelection(string);
    clipboard.setContents(selection, null);
    System.out.println("Image URL copied to clipboard.");
}

From source file:org.gephi.ui.components.ReportSelection.java

private void copyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyButtonActionPerformed

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    try {//  w w  w  .  j  a va2  s  . c  o  m
        toolkit.getSystemClipboard().setContents(new ReportSelection(this.mHTMLReport), null);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.qumasoft.guitools.compare.CompareFrame.java

void copySelectedContentsToClipboard() {
    int[] selectedRows = null;
    FileContentsListModel listModel = null;
    if (FileContentsList.getLastFocus() == file1ContentsList) {
        selectedRows = file1ContentsList.getSelectedIndices();
        listModel = file1ContentsListModel;
    } else if (FileContentsList.getLastFocus() == file2ContentsList) {
        selectedRows = file2ContentsList.getSelectedIndices();
        listModel = file2ContentsListModel;
    }// w  w  w.j  av  a 2 s.co  m

    if ((selectedRows != null) && (listModel != null)) {
        StringBuilder selection = new StringBuilder();
        for (int i = 0; i < selectedRows.length; i++) {
            ContentRow rowContents = listModel.getElementAt(selectedRows[i]);
            if (rowContents.getRowType() != ContentRow.ROWTYPE_BLANK) {
                selection.append(rowContents.getActualText()).append("\n");
            }
        }
        StringSelection stringSelection = new StringSelection(selection.toString());
        Toolkit screenToolkit = java.awt.Toolkit.getDefaultToolkit();
        screenToolkit.getSystemClipboard().setContents(stringSelection, stringSelection);
    }
}