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);
}
}
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);
}
}
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;
}
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;
}
}
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();
}
}
Aggregations