Using applets with JPEG images.
Hello.
I have an small applet that I want to display an image of a pie graph. The name of the image is "plannedparenthood.jpeg"
How do I get the applet to display the image? I tried using the getCodeBase method, but maybe I'm just not doing it right.
Thanks.
-MP-
Re: Using applets with JPEG images.
How exactly are you trying to do it, and what happens? Any errors? And just where is this image located?
Re: Using applets with JPEG images.
I just want the applet to show the image. Then I'll describe the image in paragraphs above and below the image.
I have the image in the same folder as applet.
Thanks :)
Re: Using applets with JPEG images.
Actually...it might be better if I showed some code...
Code:
import java.awt.*;
import java.applet.*;
public class TryApplet extends Applet
{
private Image image1 = null;
public void init()
{
image1 = this.getImage(this.getCodeBase() , "plannedparenthood.jpeg");
}
public void paint (Graphics g)
{
g.drawImage(image1, 0, 0, 452, 285, this );
}
}
Re: Using applets with JPEG images.
The Jpeg I am using is 452X285.
The code compiles, but I just can't see an image when I run the code.
Any help is appreciated :)
Re: Using applets with JPEG images.
How are you executing the applet? Where are all the files that are being used when executing this applet? the html, class file(s) and image?
What does the <applet tag in the html look like?
Add a println to print out the value returned by the getCodeBase() method.
Re: Using applets with JPEG images.
I'm executing the code through a simple HTML code for now. I didn't want to get too crazy with the HTML. I'm a novice on both...but I'm much better at HTML than I am at Java.
All of my files (html, java, jpeg) are in the same folder.
The applet tag looks like this...
<applet code="applet.class" width="600" height="600"> </applet>
Re: Using applets with JPEG images.
Where are you .class files?
Re: Using applets with JPEG images.
Re: Using applets with JPEG images.
Add a println to print out the value returned by the getCodeBase() method. What is printed out?
Look in the browser's java console.
Re: Using applets with JPEG images.
I updated my JRE to version 1.7
I have a 64 bit machine...and I have it in both 64 bit and 32 bit folders.
When I run the applet...it runs, but no matter what browser I use (IE, Firefox, Chrome) it tells me to download a plug in that I already have on my computer.
Could this be my problem? When I was on version 6, I could run regular applets, just not ones with JPEGS. Now I can't run any applets at all. I get a warning asking me to download a plug in that's already installed. What do I do?
Thanks
-MP-
Re: Using applets with JPEG images.
Look at the control panel's java icon. is there a setting there to turn on the java plugin?
Or look in the browsers. Is the java plugin disabled?
Re: Using applets with JPEG images.
At first it was disabled because it was out of date. So I updated it. Now it keeps asking me to update the plug in. So I did.
But it won't take the plug in. Every time I load it (and I even restart my computer afterwards) it won't run the plug in.
I'm on FireFox...the add-on I have is Java Deployment Toolkit 7.0.30.255 10.3.1.255
I'm running Windows 7 64bit.