use of java.awt.datatransfer.Clipboard in project liliths-throne-public by Innoxia.
the class ButtonCopyDialogueEventListener method handleEvent.
@Override
public void handleEvent(Event event) {
StringSelection selection = new StringSelection(Main.game.getContentForClipboard());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
}
use of java.awt.datatransfer.Clipboard in project Terasology by MovingBlocks.
the class AbstractEditorScreen method copyJson.
/**
* De-serializes the current state of the editor and copies it to the system clipboard.
*/
protected void copyJson() {
if (getEditor().getModel() != null) {
// Deserialize the state of the editor to a JSON string.
JsonElement json = JsonTreeConverter.deserialize(getEditor().getModel().getNode(0).getRoot());
String jsonString = new GsonBuilder().setPrettyPrinting().create().toJson(json);
// Set the contents of the system clipboard to it.
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
try {
clipboard.setContents(new StringSelection(jsonString), null);
} catch (IllegalStateException e) {
logger.warn("Clipboard inaccessible.", e);
}
}
}
use of java.awt.datatransfer.Clipboard in project suite by stupidsing.
the class ClipboardUtil method getClipboardText.
public String getClipboardText() {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable contents = clipboard.getContents(null);
String text;
if (contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor))
try {
text = contents.getTransferData(DataFlavor.stringFlavor).toString();
} catch (UnsupportedFlavorException ex) {
LogUtil.error(ex);
text = "";
} catch (IOException ex) {
LogUtil.error(ex);
text = "";
}
else
text = "";
return text;
}
use of java.awt.datatransfer.Clipboard in project frostwire by frostwire.
the class GUIMediator method setClipboardContent.
public static void setClipboardContent(String str) {
try {
StringSelection data = new StringSelection(str);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(data, data);
} catch (Exception e) {
e.printStackTrace();
}
}
use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.
the class JWildfireApplet method copyToClipboardBtn_clicked.
protected void copyToClipboardBtn_clicked() throws Exception {
Flame currFlame = getCurrFlame();
if (currFlame != null) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String xml = new FlameWriter().getFlameXML(currFlame);
StringSelection data = new StringSelection(xml);
clipboard.setContents(data, data);
}
}
Aggregations