Search in sources :

Example 96 with Clipboard

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);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 97 with Clipboard

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);
        }
    }
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) JsonElement(com.google.gson.JsonElement) Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 98 with Clipboard

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;
}
Also used : Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Example 99 with Clipboard

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();
    }
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) InvocationTargetException(java.lang.reflect.InvocationTargetException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LaunchException(com.limegroup.gnutella.util.LaunchException) IOException(java.io.IOException) StringSelection(java.awt.datatransfer.StringSelection)

Example 100 with Clipboard

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);
    }
}
Also used : FlameWriter(org.jwildfire.create.tina.io.FlameWriter) Clipboard(java.awt.datatransfer.Clipboard) Flame(org.jwildfire.create.tina.base.Flame) StringSelection(java.awt.datatransfer.StringSelection)

Aggregations

Clipboard (java.awt.datatransfer.Clipboard)181 StringSelection (java.awt.datatransfer.StringSelection)117 Transferable (java.awt.datatransfer.Transferable)44 IOException (java.io.IOException)30 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)16 JDialog (javax.swing.JDialog)12 JOptionPane (javax.swing.JOptionPane)12 ActionEvent (java.awt.event.ActionEvent)11 Flame (org.jwildfire.create.tina.base.Flame)10 ActionListener (java.awt.event.ActionListener)8 JButton (javax.swing.JButton)8 JScrollPane (javax.swing.JScrollPane)8 JMenuItem (javax.swing.JMenuItem)7 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