Search in sources :

Example 26 with Clipboard

use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.

the class TinaInteractiveRendererController method toClipboardButton_clicked.

public void toClipboardButton_clicked() {
    try {
        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);
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FlameWriter(org.jwildfire.create.tina.io.FlameWriter) Clipboard(java.awt.datatransfer.Clipboard) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) StringSelection(java.awt.datatransfer.StringSelection)

Example 27 with Clipboard

use of java.awt.datatransfer.Clipboard in project JWildfire by thargor6.

the class TinaSWFAnimatorController method movieToClipboardButton_clicked.

public void movieToClipboardButton_clicked() {
    try {
        updateMovieFields();
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        String xml = new FlameMovieWriter().getMovieXML(currMovie);
        StringSelection data = new StringSelection(xml);
        clipboard.setContents(data, data);
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FlameMovieWriter(org.jwildfire.create.tina.io.FlameMovieWriter) Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 28 with Clipboard

use of java.awt.datatransfer.Clipboard in project pdfbox by apache.

the class Tree method getTreePathMenuItem.

/**
 * Produce the JMenuItem that gives way to copy tree path string to clipboard
 * @param path the TreePath instance
 * @return Menu Item
 */
private JMenuItem getTreePathMenuItem(final TreePath path) {
    JMenuItem copyPathMenuItem = new JMenuItem("Copy Tree Path");
    copyPathMenuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            clipboard.setContents(new StringSelection(new TreeStatus(rootNode).getStringForPath(path)), null);
        }
    });
    return copyPathMenuItem;
}
Also used : TreeStatus(org.apache.pdfbox.debugger.treestatus.TreeStatus) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Clipboard(java.awt.datatransfer.Clipboard) JMenuItem(javax.swing.JMenuItem) StringSelection(java.awt.datatransfer.StringSelection)

Example 29 with Clipboard

use of java.awt.datatransfer.Clipboard in project keystore-explorer by kaikramer.

the class ImportCaReplyFromClipboardAction method openCaReply.

private X509Certificate[] openCaReply() {
    X509Certificate[] certs = null;
    try {
        // get clip board contents, but only string types, not files
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable t = clipboard.getContents(null);
        if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            String data;
            data = (String) t.getTransferData(DataFlavor.stringFlavor);
            ByteArrayInputStream bais = new ByteArrayInputStream(data.getBytes());
            // try to extract certs from clip board data
            certs = X509CertUtil.loadCertificates(bais);
            if (certs.length == 0) {
                JOptionPane.showMessageDialog(frame, MessageFormat.format(res.getString("ImportCaReplyFromClipboardAction.NoCertsFound.message"), "Clipboard"), res.getString("ImportCaReplyFromClipboardAction.OpenCaReply.Title"), JOptionPane.WARNING_MESSAGE);
            }
        }
        return certs;
    } catch (Exception ex) {
        String problemStr = MessageFormat.format(res.getString("ImportCaReplyFromClipboardAction.NoOpenCaReply.Problem"), "Clipboard");
        String[] causes = new String[] { res.getString("ImportCaReplyFromClipboardAction.NotCaReply.Cause"), res.getString("ImportCaReplyFromClipboardAction.CorruptedCaReply.Cause") };
        Problem problem = new Problem(problemStr, causes, ex);
        DProblem dProblem = new DProblem(frame, res.getString("ImportCaReplyFromClipboardAction.ProblemOpeningCaReply.Title"), problem);
        dProblem.setLocationRelativeTo(frame);
        dProblem.setVisible(true);
        return null;
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Transferable(java.awt.datatransfer.Transferable) DProblem(org.kse.gui.error.DProblem) Problem(org.kse.gui.error.Problem) Clipboard(java.awt.datatransfer.Clipboard) X509Certificate(java.security.cert.X509Certificate) DProblem(org.kse.gui.error.DProblem)

Example 30 with Clipboard

use of java.awt.datatransfer.Clipboard in project keystore-explorer by kaikramer.

the class ExamineClipboardAction method doAction.

/**
 * Do action.
 */
@Override
protected void doAction() {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    // get clipboard contents, but only string types, not files
    Transferable t = clipboard.getContents(null);
    try {
        if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            String data;
            data = (String) t.getTransferData(DataFlavor.stringFlavor);
            show(data);
        }
    // TODO handle other flavor types
    } catch (UnsupportedFlavorException e) {
    // ignore
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Aggregations

Clipboard (java.awt.datatransfer.Clipboard)172 StringSelection (java.awt.datatransfer.StringSelection)110 Transferable (java.awt.datatransfer.Transferable)43 IOException (java.io.IOException)27 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)15 ActionEvent (java.awt.event.ActionEvent)12 JDialog (javax.swing.JDialog)12 JOptionPane (javax.swing.JOptionPane)12 Flame (org.jwildfire.create.tina.base.Flame)10 ActionListener (java.awt.event.ActionListener)9 JButton (javax.swing.JButton)8 JMenuItem (javax.swing.JMenuItem)8 JScrollPane (javax.swing.JScrollPane)8 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