Results 1 to 13 of 13
  1. #1
    Outsider418 is offline Member
    Join Date
    May 2012
    Posts
    17
    Rep Power
    0

    Default 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-

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default 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?

  3. #3
    Outsider418 is offline Member
    Join Date
    May 2012
    Posts
    17
    Rep Power
    0

    Default 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 :)

  4. #4
    Outsider418 is offline Member
    Join Date
    May 2012
    Posts
    17
    Rep Power
    0

    Default Re: Using applets with JPEG images.

    Actually...it might be better if I showed some code...


    Java 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 );
      }
    }

  5. #5
    Outsider418 is offline Member
    Join Date
    May 2012
    Posts
    17
    Rep Power
    0

    Default 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 :)

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,317
    Rep Power
    25

    Default 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.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Outsider418 is offline Member
    Join Date
    May 2012
    Posts
    17
    Rep Power
    0

    Default 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>

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  9. #9
    Outsider418 is offline Member
    Join Date
    May 2012
    Posts
    17
    Rep Power
    0

    Default Re: Using applets with JPEG images.

    Also in the same folder

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,317
    Rep Power
    25

    Default 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.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    Outsider418 is offline Member
    Join Date
    May 2012
    Posts
    17
    Rep Power
    0

    Default 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-

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,317
    Rep Power
    25

    Default 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?
    If you don't understand my response, don't ignore it, ask a question.

  13. #13
    Outsider418 is offline Member
    Join Date
    May 2012
    Posts
    17
    Rep Power
    0

    Default 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.

Similar Threads

  1. Need Help and suggestion in handling the Jpeg images
    By naveen.dpt2007 in forum Java 2D
    Replies: 7
    Last Post: 11-06-2011, 04:49 AM
  2. Java Applets and Images
    By Danioson in forum Java Applets
    Replies: 7
    Last Post: 08-02-2010, 12:30 PM
  3. Images on JPanels with applets?
    By Krooger in forum Java Applets
    Replies: 1
    Last Post: 03-23-2010, 03:41 PM
  4. images, panels and applets
    By jamesfrize in forum Java Applets
    Replies: 3
    Last Post: 03-20-2008, 04:35 PM
  5. Problems to show images in applets
    By Felissa in forum Java Applets
    Replies: 1
    Last Post: 07-06-2007, 09:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •