I want to display an image in the applet..Can anyone say me how to do that..And i want to display the label at specified co-ordinates..How can i do this..
I'm working in NetBeans..I exectued the program..Its working well with applet viewer but in IE...I checked the permission too..Everything is well but still its not displaying in IE..What might be the reason?
Its saying that Applet loading failed.. The IE is not accepting the image file(GIF)..What should i have to do to display the image in IE?Please help me..
[ November 13, 2007: Message edited by: shalini gnana ]
My image is not getting loaded..If i comment the image part then its working..
It throws the following error:
ava.security.AccessControlException: access denied (java.io.FilePermission C:\Documents and Settings\8563\JavaApplication2\image\folder.gif 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 mining.TreeEX$ImagePanel.<init>(TreeEX.java:41) at mining.TreeEX.init(TreeEX.java:30) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
access denied (java.io.FilePermission C:\Documents and Settings\8563\JavaApplication2\image\folder.gif read)
Applets can't access the local file system. You need to rewrite the code that uses this file to load the file from the server (or the applet jar file) instead.
As said before, you can't access files on the local file system from applets unless you explicitly allow it to. You'll need to set permissions, and most likely sign the applet too.
It's better to use a relative path to the image. If your HTML file is stored in C:\Documents and Settings\8563\JavaApplication2, the following will create a relative URL for you:
No, it's a reference to the applet instance. If this code is inside of the TreeEX class (which extends Applet) then you can just write
but if the code moves to a different class -which is the case in your code- you'll need a reference to the Applet object. You could pass that into the ImagePanel class in the constructor.
Actually, no, you didn't. I suggested passing a reference to the applet instance to the ImagePanel class in its constructor. What you did was to try to create a new instance of the applet class: