本文整理汇总了Java中java.awt.datatransfer.Clipboard.setContents方法的典型用法代码示例。如果您正苦于以下问题:Java Clipboard.setContents方法的具体用法?Java Clipboard.setContents怎么用?Java Clipboard.setContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.datatransfer.Clipboard
的用法示例。
在下文中一共展示了Clipboard.setContents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
File f = FileUtil.toFile(
matchingObject.getFileObject());
if (f != null) {
String path = f.getPath();
Clipboard clipboard = Lookup.getDefault().lookup(
ExClipboard.class);
if (clipboard == null) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit != null) {
clipboard = toolkit.getSystemClipboard();
}
}
if (clipboard != null) {
StringSelection strSel = new StringSelection(path);
clipboard.setContents(strSel, null);
}
}
}
示例2: exportToClipboard
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
@Override
public void exportToClipboard(JComponent comp, Clipboard clip, int action) throws IllegalStateException {
if (action == COPY || action == MOVE) {
try {
String text = AnnotationDrawUtils.getPlaintextFromEditor(editor, true);
Transferable t = new StringTransferable(text);
try {
clip.setContents(t, null);
exportDone(comp, t, action);
return;
} catch (IllegalStateException ise) {
exportDone(comp, t, NONE);
throw ise;
}
} catch (IndexOutOfBoundsException | IOException | BadLocationException e1) {
// should not happen
exportDone(comp, null, NONE);
}
}
exportDone(comp, null, NONE);
}
示例3: jMenuItem54ActionPerformed
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
private void jMenuItem54ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem54ActionPerformed
try {
//new dialogs.Summary(this, opened).setVisible(true);
summary.summaryAll(); osEncoding.setText("Caret Position : " + Totalsel.getText());
jLabel18.setText("Current Line : " + jLabel500.getText()); jLabel19.setText("Current Column : " + jLabel501.getText());
String fileSum = "\t\t"+jLabel23.getText()+"\n"+osEncoding.getText()+"\t\t"+
jLabel18.getText()+"\n"+jLabel19.getText()+"\t\t"+jLabel20.getText()
+"\n"+jLabel21.getText()+"\t\t"+jLabel22.getText()+"\n"+jLabel16.getText()
+"\t\t"+jLabel24.getText()+"\n"+jLabel25.getText()+"\t\t"+jLabel26.getText()
+"\n"+jLabel27.getText()+"\t\t"+jLabel500.getText();
StringSelection stringSelection = new StringSelection(fileSum);
Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(stringSelection, null);
copylistModel.addElement(fileSum);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例4: actionPerformed
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Object value = editor.getValueAt(row, column);
String valStr;
if(value instanceof ParameterDisjunction){
valStr = ((ParameterDisjunction)value).getName();
}else if(value instanceof Boolean){
valStr = ((Boolean)value) ? "Required parameter" : "Optional parameter";
}else{
valStr = value.toString();
}
StringSelection data = new StringSelection(valStr);
clipboard.setContents(data, data);
}
示例5: copyChart
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
/**
* Copies the current chart to the system clipboard.
*/
public static synchronized void copyChart(final JFreeChartPlotEngine engine) {
Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Insets insets = engine.getChartPanel().getInsets();
int w = engine.getChartPanel().getWidth() - insets.left - insets.right;
int h = engine.getChartPanel().getHeight() - insets.top - insets.bottom;
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = img.createGraphics();
engine.getChartPanel().print(g2);
g2.dispose();
systemClipboard.setContents(new TransferableImage(img), null);
}
示例6: updateSystemSelection
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
private void updateSystemSelection() {
if (getDot() != getMark() && component != null) {
Clipboard clip = getSystemSelection();
if (clip != null) {
clip.setContents(new java.awt.datatransfer.StringSelection(component.getSelectedText()), null);
}
}
}
示例7: copyToClipBtnActionPerformed
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
private void copyToClipBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyToClipBtnActionPerformed
// TODO add your handling code here:
StringSelection selection = new StringSelection(cKey);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
if(cKey != null) {
clipboard.setContents(selection, selection);
}
}
示例8: menuItemIdActionPerformed
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
private void menuItemIdActionPerformed(
java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemIdActionPerformed
if (JOptionPane.showInputDialog(this, "User ID from database:", "ID", 1, null, null,
user.getId().toString()) != null) {
final StringSelection stringSelection = new StringSelection(user.getId().toString());
final Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(stringSelection, null);
}
}
示例9: copyToClipboard
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
protected void copyToClipboard(Iterator it) {
StringBuffer sb = new StringBuffer();
for (; it.hasNext(); ) {
sb.append(it.next().toString());
sb.append("\n");
}
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection ss = new StringSelection(sb.toString());
c.setContents(ss, ss);
}
示例10: copy
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
public void copy() {
StringBuffer sb = new StringBuffer();
sb.append(tempInfo);
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
String tempString = sb.toString();
tempString = tempString.replaceAll("zoom.+","");
tempString = tempString.replaceAll("[\\(\\)=,\\w&&[^WESN\\d]]+","");
String [] result = tempString.split("\\s+");
tempString = "";
for ( int i =0; i < result.length; i++ ) {
if ( result[i].indexOf("\u00B0") != -1 && result[i].indexOf("\u00B4") == -1 ) {
result[i] = result[i].replaceAll("\\u00B0","");
}
if ( i == 2 ) {
if ( result[i].indexOf("W") != -1 ) {
result[i] = "-" + result[i];
}
result[i] = result[i].replaceAll("[WE]","");
}
else if ( i == 3 ) {
if ( result[i].indexOf("S") != -1 ) {
result[i] = "-" + result[i];
}
result[i] = result[i].replaceAll("[NS]","");
}
tempString += result[i] + "\t";
}
tempString = tempString.trim();
tempString = line.getCruiseID().trim() + "\t" + line.getID().trim() + "\t" + currentTime/1000.0 + "\t" + currentCDP + "\t" + tempString;
StringSelection ss = new StringSelection(tempString + "\n");
c.setContents(ss, ss);
}
示例11: actionPerformed
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
int row = table.getSelectedRow();
if (row < 0)
return;
AddressBookEntry entry = entries.get(row);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(entry.address), null);
}
示例12: copy
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
public void copy() {
StringBuffer sb = new StringBuffer();
sb.append(tempInfo);
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
String tempString = sb.toString();
tempString = tempString.replaceAll("zoom.+","");
tempString = tempString.replaceAll("[\\(\\)=,\\w&&[^WESN\\d]]+","");
String [] result = tempString.split("\\s+");
tempString = "";
for ( int i =0; i < result.length; i++ ) {
if ( result[i].indexOf("\u00B0") != -1 && result[i].indexOf("\u00B4") == -1 ) {
result[i] = result[i].replaceAll("\\u00B0","");
}
if ( i == 2 ) {
if ( result[i].indexOf("W") != -1 ) {
result[i] = "-" + result[i];
}
result[i] = result[i].replaceAll("[WE]","");
}
else if ( i == 3 ) {
if ( result[i].indexOf("S") != -1 ) {
result[i] = "-" + result[i];
}
result[i] = result[i].replaceAll("[NS]","");
}
tempString += result[i] + "\t";
}
tempString = tempString.trim();
tempString = id + "\t" + Double.toString(currentDistance) + "\t" + tempString;
StringSelection ss = new StringSelection(tempString + "\n");
c.setContents(ss, ss);
}
示例13: main
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Producer contents = new Producer();
clipboard.setContents(contents, null);
ProcessResults processResults =
ProcessCommunicator
.executeChildProcess(Consumer.class, new String[0]);
if (!"Hello".equals(processResults.getStdErr())) {
throw new RuntimeException("transfer of remote object failed");
}
System.out.println("ok");
}
示例14: copyTextToClipboard
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
public static void copyTextToClipboard(String text) {
StringSelection stringSelection = new StringSelection(text);
Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(stringSelection, null);
}
示例15: copyStringToClipboard
import java.awt.datatransfer.Clipboard; //导入方法依赖的package包/类
/**
* Copies the given {@link String} to the system {@link Clipboard}.
*
* @param s
*/
public static void copyStringToClipboard(String s) {
StringSelection stringSelection = new StringSelection(s);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
}