use of java.awt.datatransfer.Clipboard in project jdk8u_jdk by JetBrains.
the class bug8059739 method runTest.
private static void runTest() throws Exception {
String testString = "my string";
JTextField tf = new JTextField(testString);
tf.selectAll();
Clipboard clipboard = new Clipboard("clip");
tf.getTransferHandler().exportToClipboard(tf, clipboard, TransferHandler.COPY);
DataFlavor[] dfs = clipboard.getAvailableDataFlavors();
for (DataFlavor df : dfs) {
String charset = df.getParameter("charset");
if (InputStream.class.isAssignableFrom(df.getRepresentationClass()) && charset != null) {
BufferedReader br = new BufferedReader(new InputStreamReader((InputStream) clipboard.getData(df), charset));
String s = br.readLine();
System.out.println("Content: '" + s + "'");
passed &= s.contains(testString);
}
}
}
use of java.awt.datatransfer.Clipboard in project intellij-community by JetBrains.
the class TreeCopyProvider method performCopy.
public void performCopy(@NotNull DataContext dataContext) {
try {
final Clipboard clipboard = myTree.getToolkit().getSystemClipboard();
myTree.getTransferHandler().exportToClipboard(myTree, clipboard, TransferHandler.COPY);
} catch (Exception ex) {
// probably don't have clipboard access or something
LOG.info(ex);
}
}
use of java.awt.datatransfer.Clipboard in project processing by processing.
the class ColorSelector method run.
public void run() {
if (selector == null) {
synchronized (ColorSelector.class) {
if (selector == null) {
selector = new ColorChooser(base.getActiveEditor(), false, Color.WHITE, Language.text("menu.edit.copy"), new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Clipboard c = Toolkit.getSystemClipboard();
c.setContents(new StringSelection(selector.getHexColor()), null);
}
});
}
}
}
selector.show();
}
use of java.awt.datatransfer.Clipboard in project jphp by jphp-compiler.
the class Robot method type.
@Signature
public void type(String characters) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(characters);
clipboard.setContents(stringSelection, null);
getWrappedObject().keyPress(KeyEvent.VK_CONTROL);
getWrappedObject().keyPress(KeyEvent.VK_V);
getWrappedObject().keyRelease(KeyEvent.VK_V);
getWrappedObject().keyRelease(KeyEvent.VK_CONTROL);
}
use of java.awt.datatransfer.Clipboard in project JMRI by JMRI.
the class ControlPanelEditor method copyToClipboard.
/*
* The editor instance is dragged. When dropped this editor will reference
* the list of positionables (_clipGroup) for pasting
*/
private void copyToClipboard() {
if (_selectionGroup != null) {
ArrayList<Positionable> dragGroup = new ArrayList<Positionable>();
for (Positionable comp : _selectionGroup) {
Positionable pos = comp.deepClone();
dragGroup.add(pos);
// cloned item gets added to _targetPane during cloning
removeFromTarget(pos);
}
log.debug("copyToClipboard: cloned _selectionGroup, size= {}", _selectionGroup.size());
_clipGroup = dragGroup;
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new PositionableListDnD(_clipGroup), this);
log.debug("copyToClipboard: setContents _selectionGroup, size= {}", _selectionGroup.size());
} else {
_clipGroup = null;
}
}
Aggregations