Search in sources :

Example 41 with Clipboard

use of java.awt.datatransfer.Clipboard in project energy3d by concord-consortium.

the class ClipImage method copyImageToClipboard.

public void copyImageToClipboard(Component c) {
    BufferedImage bi = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
    c.paintAll(bi.createGraphics());
    try {
        TransferableImage trans = new TransferableImage(bi);
        Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
        clip.setContents(trans, this);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) BufferedImage(java.awt.image.BufferedImage) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException)

Example 42 with Clipboard

use of java.awt.datatransfer.Clipboard in project openchemlib by Actelion.

the class TextClipboardHandler method pasteText.

public static String pasteText() {
    Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    Transferable clipboardContents = systemClipboard.getContents(null);
    if (clipboardContents != null) {
        try {
            if (clipboardContents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                return (String) clipboardContents.getTransferData(DataFlavor.stringFlavor);
            }
        } catch (UnsupportedFlavorException ufe) {
            ufe.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
    return null;
}
Also used : Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Example 43 with Clipboard

use of java.awt.datatransfer.Clipboard in project keystore-explorer by kaikramer.

the class DViewAsn1Dump method copyPressed.

private void copyPressed() {
    String policy = jtaAsn1Dump.getText();
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    StringSelection copy = new StringSelection(policy);
    clipboard.setContents(copy, copy);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 44 with Clipboard

use of java.awt.datatransfer.Clipboard in project chatty by chatty.

the class MiscUtil method copyToClipboard.

/**
 * Copy the given text to the clipboard.
 *
 * @param text
 */
public static void copyToClipboard(String text) {
    Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
    c.setContents(new StringSelection(text), null);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 45 with Clipboard

use of java.awt.datatransfer.Clipboard in project Spark by igniterealtime.

the class ChatRoomTransferDecorator method keyPressed.

public void keyPressed(KeyEvent ke) {
    if (ke.getKeyCode() == KeyEvent.VK_V) {
        int i = ke.getModifiers();
        if ((i & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) {
            Clipboard clb = Toolkit.getDefaultToolkit().getSystemClipboard();
            Transferable contents = clb.getContents(ke.getSource());
            if (contents != null && contents.getTransferDataFlavors().length == 1) {
                if (contents.isDataFlavorSupported(DataFlavor.imageFlavor)) {
                    SparkManager.getTransferManager().sendImage(SparkTransferManager.getClipboard(), chatRoom);
                }
            }
        }
    }
}
Also used : Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard)

Aggregations

Clipboard (java.awt.datatransfer.Clipboard)172 StringSelection (java.awt.datatransfer.StringSelection)110 Transferable (java.awt.datatransfer.Transferable)43 IOException (java.io.IOException)27 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)15 ActionEvent (java.awt.event.ActionEvent)12 JDialog (javax.swing.JDialog)12 JOptionPane (javax.swing.JOptionPane)12 Flame (org.jwildfire.create.tina.base.Flame)10 ActionListener (java.awt.event.ActionListener)9 JButton (javax.swing.JButton)8 JMenuItem (javax.swing.JMenuItem)8 JScrollPane (javax.swing.JScrollPane)8 JPanel (javax.swing.JPanel)7 JTextArea (javax.swing.JTextArea)7 Foundation (org.concord.energy3d.model.Foundation)7 HousePart (org.concord.energy3d.model.HousePart)7 FlameReader (org.jwildfire.create.tina.io.FlameReader)7 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)7 Point (java.awt.Point)6