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();
}
}
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;
}
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);
}
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);
}
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);
}
}
}
}
}
Aggregations