当前位置: 首页>>代码示例>>Java>>正文


Java Clipboard.setContents方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MatchingObjectNode.java

示例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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:TransferHandlerAnnotationPlaintext.java

示例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);
    }
      
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:20,代码来源:Main.java

示例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);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:16,代码来源:PRViewer.java

示例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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:CopyChartAction.java

示例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);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:BaseCaret.java

示例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);
    }
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:9,代码来源:CourseReg.java

示例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);
    }
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:10,代码来源:FClient.java

示例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);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:11,代码来源:PDB.java

示例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);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:33,代码来源:XMImage.java

示例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);
}
 
开发者ID:ca333,项目名称:komodoGUI,代码行数:9,代码来源:AddressBookPanel.java

示例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);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:33,代码来源:MGGData.java

示例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");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:DataFlavorRemoteTest.java

示例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);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:6,代码来源:Utils.java

示例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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:11,代码来源:Tools.java


注:本文中的java.awt.datatransfer.Clipboard.setContents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。