regarding the ImageIcon loading image from a JPG file

hi all, i have a strange problem where i found the following error:

[code]
java.security.AccessControlException: access denied
[/code]

when i try to load my JPG file into the Icon, why?

my code as follow:

[code]
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
Icon leafIcon = new ImageIcon("a.jpg");
renderer.setLeafIcon(leafIcon);
[/code]

Comments

  • : hi all, i have a strange problem where i found the following error:
    :
    : [code]
    : java.security.AccessControlException: access denied
    : [/code]
    :
    : when i try to load my JPG file into the Icon, why?
    :

    I'm guessing, but you're probably writing an Applet or otherwise sandboxed application that doesn't have access to the file system. Put the image on the classpath and use the Applet's ClassLoader to load it.

    ---------------------------------
    [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]

  • : : hi all, i have a strange problem where i found the following error:
    : :
    : : [code]
    : : java.security.AccessControlException: access denied
    : : [/code]
    : :
    : : when i try to load my JPG file into the Icon, why?
    : :
    :
    : I'm guessing, but you're probably writing an Applet or otherwise sandboxed application that doesn't have access to the file system. Put the image on the classpath and use the Applet's ClassLoader to load it.
    :
    : ---------------------------------
    : [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]
    :
    :

    yes, indeed, i m developing applet, so i m now trying your solution, thank you very much
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion