java类java.awt.datatransfer.StringSelection的实例源码

Terminal.java 文件源码 项目:incubator-netbeans 阅读 23 收藏 0 点赞 0 评论 0
@Override
public void copyToClipboard() {
    String text = getSelectedText();
    if (text != null) {
    StringSelection ss = new StringSelection(text);
    systemClipboard.setContents(ss, ss);
    }
}
Term.java 文件源码 项目:incubator-netbeans 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Transfer selected text into clipboard.
 */
public void copyToClipboard() {
    String text = sel.getSelection();
    if (text != null) {
        StringSelection ss = new StringSelection(text);
        systemClipboard.setContents(ss, sel);
    }
}
ClipboardJTextArea.java 文件源码 项目:JuggleMasterPro 阅读 17 收藏 0 点赞 0 评论 0
final public void doCopy() {

        final String strLtext = this.getText();
        final boolean bolLnotEmpty = !strLtext.equals(Strings.strS_EMPTY);
        if (bolLnotEmpty && this.objGcontrolJFrame.getJuggleMasterPro().bolGprogramTrusted) {
            try {
                Constants.objS_GRAPHICS_TOOLKIT.getSystemClipboard().setContents(new StringSelection(strLtext), null);
            } catch (final Throwable objPthrowable) {
                Tools.err("Error while copying program console into clipboard");
            }
        }
    }
XMImage.java 文件源码 项目:geomapapp 阅读 22 收藏 0 点赞 0 评论 0
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);
}
BasicAttachStepsProvider.java 文件源码 项目:incubator-netbeans 阅读 19 收藏 0 点赞 0 评论 0
protected void copyParameters(AttachSettings settings) {
    String parameters = parameters(settings);
    parameters = parameters.replace("&lt;", "<").replace("&gt;", ">"); // NOI18N
    StringSelection s = new StringSelection(parameters);
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(s, s);
    ProfilerDialogs.displayInfo(Bundle.AttachDialog_CopiedToClipboard());
}
CompletionLayoutPopup.java 文件源码 项目:incubator-netbeans 阅读 20 收藏 0 点赞 0 评论 0
private void pasteContent() throws HeadlessException {
    Transferable transferable = layout.getSelectedValue().getTransferable();
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    if (transferable != null) {
        clipboard.setContents(transferable, layout.getSelectedValue());
    } else {
        StringSelection contents = new StringSelection(layout.getSelectedValue().getFullText());
        clipboard.setContents(contents, layout.getSelectedValue());
    }
    getEditorComponent().paste();
}
DBConnection.java 文件源码 项目:AgentWorkbench 阅读 26 收藏 0 点赞 0 评论 0
/**
 * This method puts the value of 'toClipboard' to the clipboard
 * In case of an SQL-Error, the SQL-Statement will be placed in
 * such a way and can be used in an external application as well.
 * @param toClipboard String which will be placed in the clipboard
 */
public void put2Clipboard(String toClipboard) {
    if (Application.isOperatingHeadless()==false) {
        // --- Only in case that Agent.GUI is operated with graphical representation ------
        StringSelection data = new StringSelection(toClipboard);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(data, data);  
    }
}
CutUserAction.java 文件源码 项目:BEAST 阅读 17 收藏 0 点赞 0 评论 0
@Override
public void perform() {
    try {
        codeArea.getInsertToCode().getSaveBeforeRemove().save();
    } catch (BadLocationException ex) {
        Logger.getLogger(CutUserAction.class.getName()).log(Level.SEVERE, null, ex);
    }
    StringSelection stringSelection = new StringSelection(codeArea.getPane().getSelectedText());
    clipboard.setContents(stringSelection, null);
    codeArea.insertString("");
}
WFSViewServer.java 文件源码 项目:geomapapp 阅读 17 收藏 0 点赞 0 评论 0
public void sendToDataTables( StringBuffer[] inputSBArr ) {
    if ( inputSBArr != null && inputSBArr.length > 0 ) {
        Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
        for ( int i = 1; i < inputSBArr.length; i++ ) {
            inputSBArr[i] = inputSBArr[i].delete(0,inputSBArr[i].indexOf("\n")+1);
            inputSBArr[0].append(inputSBArr[i]);
        }
        String inputStr = inputSBArr[0].toString();
        if (inputStr.length() == 0) return;
        StringSelection ss = new StringSelection(inputStr);
        c.setContents(ss, ss);
        mapApp.importDataTable( "Import from Clipboard (paste)...", currentLayerName + " - " + currentWFSTitle );
    }
    System.gc();
}
ExactTable.java 文件源码 项目:jmt 阅读 28 收藏 0 点赞 0 评论 0
public void copyCells() {
    StringBuffer sbf = new StringBuffer();
    // Check to ensure we have selected only a contiguous block of
    // cells
    int numcols = getSelectedColumnCount();
    int numrows = getSelectedRowCount();
    int[] rowsselected = getSelectedRows();
    int[] colsselected = getSelectedColumns();
    if (!((numrows - 1 == rowsselected[rowsselected.length - 1] - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1]
            - colsselected[0] && numcols == colsselected.length))) {
        JOptionPane.showMessageDialog(null, "Invalid Copy Selection", "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE);
        return;
    }
    for (int i = 0; i < numrows; i++) {
        for (int j = 0; j < numcols; j++) {
            sbf.append(getValueAt(rowsselected[i], colsselected[j]));
            if (j < numcols - 1) {
                sbf.append("\t");
            }
        }
        sbf.append("\n");
    }
    stsel = new StringSelection(sbf.toString()) {
        @Override
        public void lostOwnership(Clipboard clipboard, Transferable contents) {
            canPaste = false;
        }
    };
    clip.setContents(stsel, stsel);
    canPaste = true;
}


问题


面经


文章

微信
公众号

扫码关注公众号