0

please don't mark this as a double, because I have searched stackoverflow already, and all the questions I can find are talking about JApplets or JFrames.

I am very new to programming, I learnt some basics off Youtube. Unfortunately, the video tutorial I watched on how to make a simple applet told me to use Applet rather than JApplet. I don't know why.

Anyway, my Applet is finished now, and all I need to do is add an icon to replace the coffee cup in Explorer/Finder.

I have the image I want set up in a "Resources" class.

public class Resources {
    static Image iconimage;
    URL url;
    static StartingPoint sp;         //StartingPoint is my main class

    public Resources(StartingPoint sp) {
        try{
            url = sp.getDocumentBase();
        }catch (Exception e){   
        }
        iconimage = sp.getImage(url, "Images/iconimage.png");

    this.sp = sp;   
    }
}

Now in my main class I have:

public class StartingPoint extends Applet{
    Image icon = Resources.iconimage;
    URL url;

    public void init() {
        setIconImage(icon);
    }
}

However I get the error: "The method setIconImage(Image) is undefined for the type StartingPoint"

Could someone please explain a fix/different method of setting the icon? Thanks a lot! I really appreciate all the help this community has been giving me.

RJrules64
  • 83
  • 2
  • 9
  • *"..the video tutorial I watched on how to make a simple applet told me to use Applet rather than JApplet. I don't know why"* 1) Why use AWT components rather than Swing? See [this answer](http://stackoverflow.com/a/6255978/418556) for many good reasons to abandon AWT. 2) Why code an applet? If it is due to spec by your instructor, please refer them to [Why CS teachers should **stop** teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). – Andrew Thompson Jul 24 '14 at 13:23
  • I completely agree with you, I'm sorry, I assumed I had made that clear in the post. By no means do I think using AWT was a good idea. I had no clue at the time however, and over 8,000 lines of code later, its a bit late to go back and change it all to Swing.. As for referring my instructor to that page, the videos he made are from 2012 so It's not really going to have an impact on his teaching style... – RJrules64 Jul 24 '14 at 15:28
  • *"the videos he made are from 2012"* And they *still* used AWT? I think it's time to find a new instructor. Next he'll have you learning COBOL. – Andrew Thompson Jul 24 '14 at 15:32

0 Answers0