// HACK: getSystemClipboard sometimes deadlocks on
// linux when called from the AWT Thread. The Thread
// creation prevents that.
@Override
		public void selectionDone(SelectionEvent evt) {
			if (!useUnixTextSelection)
				return;
			Object o = evt.getSelection();
			if (!(o instanceof CharacterIterator))
				return;
			CharacterIterator iter = (CharacterIterator) o;
			// first see if we can access the clipboard
			if (!PermissionChecker.getInstance().checkPermission(new AWTPermission("accessClipboard"))) {
				// Can't access clipboard.
				return;
			}
			int sz = iter.getEndIndex() - iter.getBeginIndex();
			if (sz == 0)
				return;
			char[] cbuff = new char[sz];
			cbuff[0] = iter.first();
			for (int i = 1; i < cbuff.length; ++i) {
				cbuff[i] = iter.next();
			}
			final String strSel = new String(cbuff);
			// HACK: getSystemClipboard sometimes deadlocks on
			// linux when called from the AWT Thread. The Thread
			// creation prevents that.
			new Thread() {
				@Override
				public void run() {
					Clipboard cb;
					cb = Toolkit.getDefaultToolkit().getSystemClipboard();
					StringSelection sel;
					sel = new StringSelection(strSel);
					cb.setContents(sel, sel);
				}
			}.start();
		}
}
final String strSel = new String(cbuff);
// HACK: getSystemClipboard sometimes deadlocks on
// linux when called from the AWT Thread. The Thread
// creation prevents that.
new Thread() {
@Override
}
int sz = iter.getEndIndex() - iter.getBeginIndex();
if (sz == 0)
return;
char[] cbuff = new char[sz];
cbuff[0] = iter.first();
for (int i = 1; i < cbuff.length; ++i) {
cbuff[i] = iter.next();
}
final String strSel = new String(cbuff);
// HACK: getSystemClipboard sometimes deadlocks on
// linux when called from the AWT Thread. The Thread
// creation prevents that.
new Thread() {
@Override
public void run() {
Clipboard cb;
cb = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection sel;
sel = new StringSelection(strSel);
cb.setContents(sel, sel);
}
}.start();
if (!useUnixTextSelection)
return;
Object o = evt.getSelection();
if (!(o instanceof CharacterIterator))
return;
CharacterIterator iter = (CharacterIterator) o;
// first see if we can access the clipboard
if (!PermissionChecker.getInstance().checkPermission(new AWTPermission("accessClipboard"))) {
// Can't access clipboard.
return;
}
int sz = iter.getEndIndex() - iter.getBeginIndex();
if (sz == 0)
return;
char[] cbuff = new char[sz];
cbuff[0] = iter.first();
for (int i = 1; i < cbuff.length; ++i) {
cbuff[i] = iter.next();
}
final String strSel = new String(cbuff);
// HACK: getSystemClipboard sometimes deadlocks on
// linux when called from the AWT Thread. The Thread
// creation prevents that.
new Thread() {
@Override
public void run() {
Clipboard cb;
cb = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection sel;
sel = new StringSelection(strSel);
cb.setContents(sel, sel);
}
}.start();
}