use of java.awt.datatransfer.StringSelection 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.StringSelection in project hid-serial by rayshobby.
the class GClip method copyString.
/**
* Copy a string to the clipboard. If the Clipboard has not been created
* then create it.
* @return true for a successful copy to clipboard
*/
private boolean copyString(String chars) {
if (clipboard == null)
makeClipboardObject();
if (clipboard != null) {
StringSelection fieldContent = new StringSelection(chars);
clipboard.setContents(fieldContent, this);
return true;
}
return false;
}
use of java.awt.datatransfer.StringSelection in project limelight by slagyr.
the class TextModelTest method canMakeUseOfTheClipboard.
@Test
public void canMakeUseOfTheClipboard() {
assumeTrue(TestUtil.notHeadless());
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection("This Text"), model);
String clipboard = model.getClipboardContents();
assertEquals("This Text", clipboard);
}
use of java.awt.datatransfer.StringSelection in project limelight by slagyr.
the class TextModelTest method reportsChangeWhenTextIsPasted.
@Test
public void reportsChangeWhenTextIsPasted() throws Exception {
assumeTrue(TestUtil.notHeadless());
model.setText("blah");
model.resetChangeFlag();
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection("yum"), model);
model.pasteClipboard();
assertEquals(true, model.hasChanged());
}
use of java.awt.datatransfer.StringSelection in project limelight by slagyr.
the class TextInputKeyProcessorTest method cmdVPastesAtCursor.
@Test
public void cmdVPastesAtCursor() {
setupSingleLine("Bob");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(" Dole"), model);
processor.processKey(new KeyPressedEvent(CMD, KeyEvent.KEY_V, 0), model);
assertEquals(model.getEndLocation(), model.getCaretLocation());
assertEquals("Bob Dole", model.getText());
}
Aggregations