Solved

Gif doesn't showup in JApplet

Posted on 1998-07-21
5
180 Views
Last Modified: 2010-04-16
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
Comment
Question by:andrewma
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:msmolyak
ID: 1227303
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
 

Author Comment

by:andrewma
ID: 1227304
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
 
LVL 5

Expert Comment

by:msmolyak
ID: 1227305
Toolkit.getDefaultToolkit() returns the default toolkit for the current platform.
0
 

Author Comment

by:andrewma
ID: 1227306
So where do you store it ?  You cannot define a Toolkit tool = Toolkit.getDefaultToolkit () to store it, because it is abstract.
0
 
LVL 5

Accepted Solution

by:
msmolyak earned 100 total points
ID: 1227307
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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 50
tomcat not starting 6 45
MySqlDump not dumping triggers 1 30
CSV file parsing thru Java 13 26
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now