• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Want to insert image in frame

 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This is Kajol..
I want to insert an image in my frame ...
I cant use URL codebase as it needs an applet which should be extended ...but my file in which i have to insert an image extends an frame...
PLease help me out...
Kajol
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,
Please wake up..
why no replies..
I need to implement it..
Kajol
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys wake up,
Whys is not anybody replying to me
Is there some problem in my asking the question..
Hello
Reply me
Kajol
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kajol,

You will need to use the Toolkit class in java.awt to load an Image outside of an applet. Toolkit.getDefaultToolkit() gives you an instance of the default toolkit you can use to load images with. There are several methods you can use to load images in this class, so look at the API docs to choose an appropriate one.

HTH,
-N8
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nathan,
Thanks for replying me..
Can u explain me with some example..
That woulld be really nice..
Kajol
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is exactly what you want... but here goes...


HTH,
-Nate
 
prashant pachouri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If u use web based application try to instantiate the dialog/clas which extens frame from an applet and use the applet's codebase to refer to the image/image directory.
Also try "getDefaultToolKit()" or "getToolKit()" method of the frame. The toolkit object thus obtained will contain a method to add/get an image.
Get back for any further clarification.

Originally posted by Kajol Shroff:
Hi,
This is Kajol..
I want to insert an image in my frame ...
I cant use URL codebase as it needs an applet which should be extended ...but my file in which i have to insert an image extends an frame...
PLease help me out...
Kajol

 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nathan/ Prashant,
Sorry to say but i couldnt view the image after i compiled the code u have given..
Can u explain it to me..
Waiting for ur reply
Kajol
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi nathan,
I am sorry but ultimately i got the image in my feame.. but am facing some other problem..
see i have inserted the main method in my Frame class.. so I have changed the creation of the object from
ImageFrame f = new ImageFrame();
to
FirstPanel f = new FirstPanel();
but am getting some problem with the WindowListeners.. when I compile it ..
it says.... cannot resolve the symbol the method ..
addWindowListeners()
Can u please help me out in this..
Kajol
[This message has been edited by Kajol Shroff (edited May 28, 2001).]
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
Reply me please...
Kajol
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nathan,
I tried your code and i could insert the image in the Frame.. and I viewed it in Appletviewer and it worked fine..
But the problem is when I viewed it in browser it gives me error
"com.ms.security.SecurityExceptionEx[FirstPanel.<init>]: cannot access file gtrace_logo.gif"
Can u plese tell me where is the problem ..what should I do..
Kajol

[This message has been edited by Kajol Shroff (edited May 30, 2001).]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry... some changes need to be made to my code for it to work in an Applet....

New ImageFrame class...




An applet that launches an ImageFrame...


Hope that this one works better for you...
-Nate
 
Kajol Shroff
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nathan,
I tried ur code.. but the problem is it is giving me security execption when i view it in Browser and when i view it in appletviewer it displays me the image..
Can u help me out in this...
Kajol
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may need to clear out your cache... the original program was running fine in AppletViewer, but giving me a security exception in IE, too... I think it may have been because I was trying to load a file in a way that the browser didn't approve of ( using Toolkit ) However, when I tested the new program it ran fine in both... but I had to clear out my cache because IE was still looking at the old copy of ImageFrame...

I tested it under IE 4.0 ( the only browser I have here at work )...

HTH,
-Nate
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic