3

Here is the function that i want to use in a web page and want to call it in script node as other javascript functions. But could you please guide me on how to achieve it.

public static String getClipboard() {

    Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);

    try {
        if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            String text = (String)t.getTransferData(DataFlavor.stringFlavor);
            return text;
        }
    } catch (UnsupportedFlavorException e) {
    } catch (IOException e) {
    }
    return null;
}

I am completely new to this concept.. If you can answer this question, that will be very helpful.. Thanks

Exception
  • 8,111
  • 22
  • 85
  • 136

2 Answers2

1

You can only call interact with Java if it's running on a Java Applet.

If you need to interact with the clipboard in Javascript, this Stack Overflow question answers that for you.

Community
  • 1
  • 1
lsoliveira
  • 4,560
  • 3
  • 20
  • 31
  • is correct. Apart from that you can execute it at server side using Ajax call and then update DOM accordingly. – Sid Dec 16 '11 at 19:12
  • @SidCool Sure. I was referring to client side interaction only (which seems to be what the parent poster was interested in). – lsoliveira Dec 16 '11 at 22:50
1

Use LiveConnect to enable bidirectional communication between Java and JavaScript within a page.

Andrew Gilmartin
  • 1,776
  • 12
  • 12