Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Applet Image

Options
  • 24-11-2004 5:30pm
    #1
    Registered Users Posts: 234 ✭✭


    Hi, i have another problem with an applet. I had an applet extending JPanel and running from another file called Target.class. This worked perfectly, there is over 1, 000 lines of code in it and its all running smoothly.

    I then tried to run it as an applet using only one .class file called PaintApplication which extends Applet. Again this all runs fine except the image doesnt load in my browser. The image is in the right directory, the program is running prefectly as an applet, just the image wont load. I wont copy and paste the full code but ill paste the code where the image is loaded and my .html applet code.


    public void paintComponent(Graphics argGraphic)
    {
    Graphics2D g2d = (Graphics2D)argGraphic; g2d.setColor(Color.black); .
    g2d.fillRect(0, 0, getSize().width, getSize().height);
    g2d.drawImage(objImage, 10, 40, this);
    }

    <html>
    <body>
    <applet code="PaintApplication.class" width=550 height=530>
    </applet>
    </body>
    </html>

    I have tried adding <param name = "ireland.gif"> etc... The image loads but then the applet just paints over it.
    Just to reiterate, it was running perfectly (image and all)with the exact same code but now i am extending Applet instead of JPanel, now the code runs fine but the image isnt drawn.

    Am i missing something simple?
    Thanks in advance.


Comments

  • Registered Users Posts: 261 ✭✭HaVoC


    not sure. do you get any errors ?(double click on the coffee cup thing to see errors for an applet) could be using paintComponents() over paint() not really sure about that tho.
    The only thing i can think of is the way you load the file,i think its differant to an application.
    Try something like:

    Image objImage= this.getImage(this.getCodeBase(),filename);


  • Registered Users Posts: 234 ✭✭Yelnahs


    Right, thanks for your reply and i reckon that would of worked, but i decided to revert back to the previous version which was working fine. So have done this now and you can view it here if you wish
    HERE

    Now the problem is that i am loading the Target.class file which starts up the PaintApplication program, because it does this the target class loads on the actual website as a grey box with an X in it as you can see from the site above. Is there anyway i can create like a hyper link to the Target.class file that then loads up the PaintApplication without actually putting the target.class file on the page itself.

    Thanks in advance, and thank you HaVoc for your input.


Advertisement