• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Applets and Images!

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I am using an Image in my applet. It runs fine when I view it on my Computer. But when I uploaded it to my server it stopped running.Only the Image portion.Rest of the applet is running fine.I also uploaded the Image which I am using in my applet.
Any answers...
Regards
Usman
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usman,
It would help alot if you posted the source code...
It could be alot of problems... image not in the place where the applet is looking for it, server lag, or the way you are trying to get the image...
-Nate
 
usman ahmad
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is the code
import java.awt.*;
import java.applet.*;
public class LoadImage extends Applet
{
private Image egg;
public void init()
{
egg = getImage(getDocumentBase(),"egg.gif");
}
public void paint(Graphics g)
{
setBackground(Color.white);
g.drawImage(egg,1,1,this);
g.drawString("Planning to Develop your WebSite!",100,50);
g.drawString("Give Usman Ahmad a crack at it.",100,300);
}

}
I hope this is helpful.
Thanks& Regards.
Usman
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm... the code works fine...
Can you post the URL of where you have this on the Internet?
Is the image or applet in a subdirectory?
-Nate
 
usman ahmad
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is the url where it is
http://www.angelfire.com/yt2/resume1/testthread.htm
check it out.
Regards
Usman

[This message has been edited by usman ahmad (edited March 23, 2001).]
 
usman ahmad
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by usman ahmad:
here is the url where it is
http://www.angelfire.com/yt2/resume1/testthread.htm
check it out.
Regards
Usman


 
usman ahmad
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually there are two applets running on this page.
Both the class file and the image and the html page are in the same Directory.
Regards
Usman
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm.... I am not sure why the Image is not showing up... try the following code to see if it helps any, but if it doesn't I am stumped...
Using MediaTracker like this helps to ensure that Images are loaded completely before they are displayed...
 
usman ahmad
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tried this also but the image part is missing still.
Thanks anyways!
Regards
Usman
 
usman ahmad
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! What now I did is explicitly called the img.
you can check it here
http://www.angelfire.com/resume1/testthread.htm
But the image still won't run in the applet.
Any help!
Regards
Usman
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usman,
Ah ha! Now I know what the problem is! But I don't think you will like the answer....
Java does not directly support animated gifs... the first frame of the animated gif is blank, and so your applet is displaying only the first, blank frame of the gif you are trying to load...
To get your applet to work, what you'll basically have to do is have two images... the whole egg and the broken egg... have a thread to control the animation... start the animation with the whole egg at the top of the screen, move the egg down the screen, and when it reaches a certain point switch the image to the broken egg and stop moving the egg down...
Is this explaination is good enough for you to figure out what to do? If not, post again, and I will try to post some code that will help you out...
HTH,
-Nate
 
usman ahmad
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nate, But shouldn't it then not display when I view it in the browser on my computer. But I can see it. Anyways, show me the code with which I can do that.
Thanks!
Regards,
Usman
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usman,
I checked out what you said, and sure enough... I was wrong... I dl'ed your egg image from the web and ran it in appletviewer and in IE4... and it worked! Guess I have egg on my face, eh? However, I uploaded the graphic to my crappy free webpage and tried it and... it didn't run! I then changed the code to load and display a static gif and the code worked... ( Check it out here at... http://members.fortunecity.com/nepruett/UsmanImage.html my crappy website ) I have no idea what is wrong... but the problem seems to be with the image and not the applet...
HTH,
-Nate
P.S. - I am working on the code that will take the animation out of the image and put it into the applet... I think this may solve your problem...
[This message has been edited by Nathan Pruett (edited March 28, 2001).]
 
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm....I'm using Netscape and it works fine for me!
With Respect,
Matt
 
Matt DeLacey
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you need to clear your caches. In IE I can't figure out how to do it (I know how you're supposed to be able to do it), but in Netscape, it's pretty straightforward. Give that a shot...maybe it's already fixed and you're just seeing an old copy.
Matt
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usman,
Here is the updated java source for animating with an applet and not with an image... just a quick and dirty example, but it works...

You can see it run and grab the image files I ripped out of your animated gif at my crappy website ( http://members.fortunecity.com/nepruett/UsmanImage.html )
HTH,
-Nate
 
Matt DeLacey
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm...strange Usman's works fine for me, but Nathan's does not.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Matt,
Do you mean that it worked fine on your machine ( appletviewer or local web browser ), or on the actual website? When I look at the original applet on my local machine, it works great... but when I put it on the server the egg image disappeared... If you are trying to run my applet on your local machine you will also need the 6 images that I ripped out of the animated gif in the same directory as the applet... It should run from my website fine.
HTH,
-Nate
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ooops!
I went to check my site and the images were not showing due to a bad HTML tag...
Sorry, they should be showing now!
-Nate
 
usman ahmad
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I will be trying this soon.
Thanks
Regards,
Usman
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic