Search code examples
javaswingjava-web-start

Java Swing - Copy / Paste doesn't work when in Java Web Start


I created a textfield in Java Swing

txtSessionID = new JTextField();
txtSessionID.setText("enter here");
txtSessionID.setBounds(6, 22, 438, 28);
frame.getContentPane().add(txtSessionID);

When I try to copy something into the textfield it works if I run the jar on desktop but not if I start it with Java Web Start.

The Question:

Why is this so? And How do I make CCP work in the JWS forms?


Solution

  • The reason for the altered behaviour can be found in Copy in sand-boxed app. in 1.6.0_24+. The security bug fix applies to both applets & JWS apps.

    The solution (again outlined in the linked thread) is to use the JNLP API's ClipboardService instead. Here is a demo. of the ClipboardService.