Results 1 to 4 of 4
  1. #1
    AZMichael is offline Member
    Join Date
    Jan 2008
    Posts
    16
    Rep Power
    0

    Default Copy from Clipboard in japplet

    Hi.

    I created an application that uses JTable as a spreadsheet, and wrote the necessary codes to cut/copy/paste to and from the clipboard to the jtable. So far, no problems when running the program as an application, or as an applet in the IDE. But, now that it's posted to the website, I cannot paste to the table. Here is the error the JAVA console gives me (looks like a security issue):

    Exception in thread "AWT-EventQueue-36" java.security.AccessControlException: access denied (java.awt.AWTPermission accessClipboard)
    at java.security.AccessControlContext.checkPermission (Unknown Source)
    at java.security.AccessController.checkPermission(Unk nown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkSystemClipboardAcce ss(Unknown Source)
    at sun.awt.windows.WToolkit.getSystemClipboard(Unknow n Source)
    at JFlashTable.GetClipBoard(JFlashTable.java:637)
    at JFlashTable.Paster(JFlashTable.java:685)
    at JFlashTable.actionPerformed(JFlashTable.java:608)
    at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.AbstractButton.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unk nown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mou seReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    The funny thing is, if I do a "control-V", I can paste the clipboard contents into a textbox, but that does not solve my problem, since I need the data to be pasted into the jtable. (they're columns of numbers, so it's not so easy to dump from textbox to jtable - I've already considered that)

    Thanks for your help.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,558
    Rep Power
    23

    Default

    java.security.AccessControlException: access denied (java.awt.AWTPermission accessClipboard)
    You need to give the applet permission to access the clipboard.
    There are two ways to do that:
    Make an entry in your .java.policy file.
    Sign the applet's jar file.

    There are several posts here on the forum on how to do that.

  3. #3
    AZMichael is offline Member
    Join Date
    Jan 2008
    Posts
    16
    Rep Power
    0

    Default

    OK, thanks, but if I make an entry in my .java.policy file, doesn't this only apply to applets running on my machine? or does the policy extend to anyone using the applet from other computers?
    Last edited by AZMichael; 09-06-2008 at 05:58 AM. Reason: found stuff on signing jar files

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,558
    Rep Power
    23

    Default

    A .java.policy entry only applies on the machine it is on. If you want other machines to be able to grant permission to your code, you'll need to sign the jar file.

Similar Threads

  1. Replies: 0
    Last Post: 07-07-2008, 04:35 PM
  2. SWT Clipboard Example
    By Java Tip in forum SWT
    Replies: 0
    Last Post: 07-07-2008, 04:34 PM
  3. [SOLVED] Creating List of Values Using ClipBoard Object
    By Judoon_Platoon in forum Java Applets
    Replies: 2
    Last Post: 05-21-2008, 08:07 AM
  4. Using the clipboard
    By Java Tip in forum java.awt.datatransfer
    Replies: 0
    Last Post: 04-16-2008, 10:52 PM
  5. Sending Image Objects through the Clipboard
    By Java Tip in forum java.awt.datatransfer
    Replies: 0
    Last Post: 04-16-2008, 10:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •