|
|
@ -1,10 +1,8 @@
|
|
|
|
package me.goudham;
|
|
|
|
package me.goudham;
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Toolkit;
|
|
|
|
import java.awt.Toolkit;
|
|
|
|
import java.awt.datatransfer.Clipboard;
|
|
|
|
import java.awt.datatransfer.*;
|
|
|
|
import java.awt.datatransfer.ClipboardOwner;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.awt.datatransfer.DataFlavor;
|
|
|
|
|
|
|
|
import java.awt.datatransfer.Transferable;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ClipboardListener extends Thread implements ClipboardOwner {
|
|
|
|
public class ClipboardListener extends Thread implements ClipboardOwner {
|
|
|
|
|
|
|
|
|
|
|
@ -18,9 +16,8 @@ public class ClipboardListener extends Thread implements ClipboardOwner {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void lostOwnership(Clipboard c, Transferable t) {
|
|
|
|
public void lostOwnership(Clipboard c, Transferable t) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
System.out.println("Sleeping for 200 milliseconds");
|
|
|
|
|
|
|
|
sleep(200);
|
|
|
|
sleep(200);
|
|
|
|
} catch (Exception ignored) { }
|
|
|
|
} catch (InterruptedException ignored) { }
|
|
|
|
|
|
|
|
|
|
|
|
Transferable contents = c.getContents(currentThread());
|
|
|
|
Transferable contents = c.getContents(currentThread());
|
|
|
|
processContents(contents);
|
|
|
|
processContents(contents);
|
|
|
@ -34,7 +31,7 @@ public class ClipboardListener extends Thread implements ClipboardOwner {
|
|
|
|
if (entryListener != null) {
|
|
|
|
if (entryListener != null) {
|
|
|
|
entryListener.onCopy(what);
|
|
|
|
entryListener.onCopy(what);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception ignored) { }
|
|
|
|
} catch (UnsupportedFlavorException | IOException ignored) { }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void regainOwnership(Clipboard c, Transferable t) {
|
|
|
|
public void regainOwnership(Clipboard c, Transferable t) {
|
|
|
|