Hey, I'm hoping someone can give me a hand here...I'm currently writing a JApplet which uses several buttons on several different JPanels.
Two of these buttons use an image and label (e.g. I did contestant.setIcon(cc); contestant.setText("C.C.");
where contestant is the button, and all formatting occurs just after and the Image was instantiated using ImageIcon cc = new ImageIcon("cc.jpg")
earlier.)
Unrelated, but if you click the buttons, the icons and labels change.
Now here's the thing: when I run as an applet within my IDE, everything works perfectly. When I write up a quick HTML file and try to run the applet in it, I get an error as soon as it tries to load the images:
java.security.AccessControlException: access denied (java.io.FilePermission cc.jpg read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at sun.awt.SunToolkit.getImageFromHash(Unknown Source)
at sun.awt.SunToolkit.getImage(Unknown Source)
at javax.swing.ImageIcon.<init>(Unknown Source)
at javax.swing.ImageIcon.<init>(Unknown Source)
at Contestants.addStuff(Contestants.java:48)
at Contestants.<init>(Contestants.java:32)
at TopPanel.<init>(TopPanel.java:26)
at FTVLeague.init(FTVLeague.java:28)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.security.AccessControlException: access denied (java.io.FilePermission cc.jpg read)
I'm not sure how to work around this error; I haven't the slightest clue why it would pull up an access denied error (especially when it works just fine out of my IDE). After a lot of web searching, the only solutions I could find all used buffered images - which you can't apply to JButtons (can only use ImageIcon - which can be converted from an Image).
If anyone could give me a hand with a work around, I'd greatly appreciate it. If there's any part of my code you think you need to see, I'll supply snippets.