# File not found using surface.setIcon(icon) in public class test extends PApplet

**URL:** <https://discourse.processing.org/t/file-not-found-using-surface-seticon-icon-in-public-class-test-extends-papplet/45622>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [January 19, 2025, 7:57am UTC](https://discourse.processing.org/t/file-not-found-using-surface-seticon-icon-in-public-class-test-extends-papplet/45622 "2025-01-19T07:57:15Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 19, 2025, 4:32pm UTC](https://discourse.processing.org/t/file-not-found-using-surface-seticon-icon-in-public-class-test-extends-papplet/45622/5 "2025-01-19T16:32:25Z")

</div>

Your question is marked ‘homework’ so according to forum rules we cannot give you a “full code” solution.

The following is the approach that I would use:

1. Delete “public”; not necessary.
2. Change name of test class to class Test extends PApplet.
3. Inside of class Test create a Test() function.
4. Inside of Test() add the following:

```auto
  PApplet.runSketch(new String[]{this.getClass().getName()}, this);
  surface.setTitle("PApplet");
  String imgPath = "Users/yourName/Documents/Processing/sketchFolderName/data/logo.png";
  img = loadImage(imgPath); // 加载图片
  if (img == null) {
    println("图片加载失败！");
  }

```

1. Add a settings() function to your Test class:

```auto
 void settings() {
    size(400, 400, P2D);
  }

```

1. Inside of draw() call the image: image(img,0,0)
2. Delete the ‘main’ function and replace it with a separate setup() function _outside_ of the Test class.
3. Inside of the separate setup() call the new Test() like this: Test test = new Test();
4. Inside of the separate setup() use surface.setVisible(false); if you don’t want to see the default Processing window.

I know it’s a lot, but I hope it helps you.

**Addendum:**  
The question title suggests that you are interested in surface.setIcon(). If that is the case, and you are using the Windows operating system the following reference may be helpful:

> [@App Icon Processing 4](https://discourse.processing.org/t/app-icon-processing-4/43918/5):
>
> Hello @Edenstudent, This is what I see with Processing 4.3 on W10: Setting icon in settings(): How cool is that! slight_smile

---

_[View the full topic](https://discourse.processing.org/t/file-not-found-using-surface-seticon-icon-in-public-class-test-extends-papplet/45622)._
