use of java.awt.datatransfer.StringSelection in project tigervnc by TigerVNC.
the class CConn method serverCutText.
public void serverCutText(String str, int len) {
StringSelection buffer;
if (!acceptClipboard.getValue())
return;
ClipboardDialog.serverCutText(str);
}
use of java.awt.datatransfer.StringSelection in project cayenne by apache.
the class LogConsole method copy.
/**
* Copies selected text from the console to system buffer
*/
public void copy() {
String selectedText = view.getLogView().getSelectedText();
// If nothing is selected, we copy the whole text
if (Util.isEmptyString(selectedText)) {
Document doc = view.getLogView().getDocument();
try {
selectedText = doc.getText(0, doc.getLength());
} catch (BadLocationException e) {
return;
}
}
Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection data = new StringSelection(selectedText);
sysClip.setContents(data, data);
}
use of java.awt.datatransfer.StringSelection in project suite by stupidsing.
the class ClipboardUtil method setClipboardText.
public void setClipboardText(String text) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(text), null);
}
use of java.awt.datatransfer.StringSelection in project Payara by payara.
the class ErrorDisplayDialog method showText.
/**
* Manages the dialog box to display whatever error information has already
* been formatted.
*
* @param text message to display
* @param rb ResourceBundle containing the i18n strings
*/
private static void showText(final String text, final ResourceBundle rb) {
ErrorDisplayDialog.rb = rb;
/*
*The JOptionPane class will accept other Components as elements of
*the dialog box. Build a JTextArea containing the stack trace. Do not
*let the user edit the text.
*/
JTextArea stackTraceArea = new JTextArea();
stackTraceArea.setEditable(false);
stackTraceArea.setRows(16);
stackTraceArea.setText(text);
/*
*Place the text area inside a scroll pane.
*/
JScrollPane sp = new JScrollPane(stackTraceArea);
/*
*Build a check box for the user to click to copy the error information
*to the platform's clipboard.
*/
JCheckBox copyToClipboardCB = new JCheckBox(getString("jwsacc.errorDialog.copyToClipboardLabel"));
/*
*Display the dialog box that also contains the text area's scroll
*pane and the checkbox and then wait for the user to close it.
*/
boolean copyToClipboard = showDialog(getString("jwsacc.errorDialog.mainMessage.1") + LINE_SEP + getString("jwsacc.errorDialog.mainMessage.2"), sp, copyToClipboardCB);
if (copyToClipboard) {
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection ss = new StringSelection(stackTraceArea.getText());
try {
cb.setContents(ss, null);
} catch (Throwable e) {
/*
*If we cannot copy the text to the clipboard, tell the user that
*and suggest that he or she manually copy it.
*/
showDialog(getString("jwsacc.errorDialog.errorCopyingMessage.1") + LINE_SEP + getString("jwsacc.errorDialog.errorCopyingMessage.2"), sp, null);
}
}
}
Aggregations