问题
Since Apple forced the update to JDK 7 on Mac, old AWT applets no longer support copy/paste. For example, if you visit:
Simple AWT Textfield Example
you cannot copy and paste into the applet text field on that page. I've confirmed that you can still copy/paste in AWT on Windows with JDK 7.
Anybody know a workaround?
回答1:
Oracle released Java 6 Update 24 in February 2011 to remedy 21 vulnerabilities: Announcement
As part of this security release, the ability to copy & paste from a computer's clipboard into a Java applet has been disabled.
To fix this issue there are 2 solutions:
- Create a digital signature for the applet.
- Work around: If you do not want to work with the digital signature, add to your java.policy file the following line: permission java.awt.AWTPermission "accessClipboard"
回答2:
Here is a great and very detailed walk-through to do it the official Java way using their policy tool:
http://www.shodor.org/interactivate/resources/InstructionsCopyPaste/
Here is a quick summary of the instructions:
- in Terminal.app type "policytool" and hit [Enter]
- dismiss any error message and choose "Save" from the "File" menu
- save as ".java.policy" (with a preceding dot) in your user's home directory
- click "Add Policy Entry" and then "Add Permission"
- choose "AWTPermission" as the permission and "accessClipboard" as the target
- click "OK", then "Done"
- choose "Save" again, then "Exit" from the "File" menu
- restart your browser (or your computer if copy/paste still doesn't work)
回答3:
Until they fix the bug, I've found that signing the applet allows copy/paste to work.
来源:https://stackoverflow.com/questions/13074496/any-workaround-to-getting-copy-paste-working-in-jdk-7-awt-applet-on-mac