This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Image is not getting displayed  RSS feed

 
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: 42975
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: 42975
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: 42975
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: 21421
94
Chrome Eclipse IDE Java 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: 42975
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: 42975
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!