Clipboard

General Discussion on RSyntaxTextArea.

Moderator: robert

Clipboard

Postby Guest » Fri Apr 08, 2011 6:51 am

I have a JWS that uses RSyntaxTextArea, but it is unable to use the clipboard unless I sign the app. There is an alternate API that is able to access the clipboard, even without the app signed. Would it be possible to support this? Below is the code showing how to do it. You need the javaws.jar from your JRE/lib directory to compile it (but not at runtime). It would be great if RSyntaxTextArea could fallback to this when the system clipboard fails, and then if the JWS API fails (or is not a JWS app or whatever), it could fallback again to the internal clipboard.

Code: Select all
try {
   ClipboardService clipboard = (ClipboardService)ServiceManager.lookup("javax.jnlp.ClipboardService");

   StringSelection ss = new StringSelection("Java Web Start!");
   clipboard.setContents(ss);

   Transferable transfer = clipboard.getContents();
   if (transfer.isDataFlavorSupported(DataFlavor.stringFlavor)) {
      try {
         String s = (String)transfer.getTransferData(DataFlavor.stringFlavor);
      } catch (Exception ignored) {
      }
   }
} catch (UnavailableServiceException ignored) {
}


-Nate
Guest
 

Re: Clipboard

Postby robert » Fri Apr 08, 2011 12:17 pm

I remember hearing about this recently. They mucked with copy/paste functionality in applets in 6u24, right? Sigh.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 1 guest