Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Image is not getting displayed

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..

 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to reduce the size of the image..How can i do it?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Changes:
 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by shalini gnana:
Its saying that Applet loading failed..


Why does applet loading fail - there should be an exception in the Java Console - what does it say?
 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)

 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.i'm not getting you..Can you please explain me little bit elobrately...
Please help me..
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show us the code that uses folder.gif. Then it'll be easier to explain what's going wrong, and how to fix it.
 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is where i'm getting error...
Please help me..
 
Sheriff
Posts: 22004
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here,myapplet is my applet class name?
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to add in the way you said..But its throwing nullPointer Exception...

 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I tried to add in the way you said..


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:

I mentioned to you that one should never do that in your question about Gantt charts.
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic