• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Gif doesn't showup in JApplet

I have a JApplet which will bring up another JFrame with some gif pictures.  Since the JApplet contains the "public static void main", it calls up the JFrame and the gif load up without any problem.  However, once we put it up onto a web server.  It returns some kind messages like "the gif is not permitted to load up".  I have set the codebase=./ .  However it still doesn't work.  Can anybody tell me how to solve this ?
0
andrewma
Asked:
andrewma
  • 3
  • 2
1 Solution
 
msmolyakCommented:
How are you loading the image? In the application you are probably getting it from a local file using that file name. In case of an applet you have to use Toolkit.getImage(URL myUrl) method. To construct a URL use Applet.getDocumentBase() method which returns the URL of the HTML file containing the APPLET tag. You should be able to build a URL of the image based on that.
0
 
andrewmaAuthor Commented:
Thanks for your reponse.  I need a futher clarification on the ToolKit part.  Since ToolKit is abstract, how can you instantiate it to invoke the getImage method ?
0
 
msmolyakCommented:
Toolkit.getDefaultToolkit() returns the default toolkit for the current platform.
0
 
andrewmaAuthor Commented:
So where do you store it ?  You cannot define a Toolkit tool = Toolkit.getDefaultToolkit () to store it, because it is abstract.
0
 
msmolyakCommented:
That's exactly what you do. Even though Toolkit type is abstract it does not mean that you cannot assign the values of subclass of a Toolkit class to a variable of Toolkit type.

Toolkit.getDefaultToolkit() returns a concrete subclass of Toolkit class.

It would be more productive if you ask additional questions without rejecting the answer. Reject the answer only if you think it is incorrect or incomplete and the additional info is not furnished.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now