# Change Icon in GWindow in G4P?

**URL:** <https://discourse.processing.org/t/change-icon-in-gwindow-in-g4p/44780>\
**Category:** Libraries\
**Created:** [July 18, 2024, 10:28am UTC](https://discourse.processing.org/t/change-icon-in-gwindow-in-g4p/44780 "2024-07-18T10:28:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thundercat](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Thundercat](https://discourse.processing.org/u/Thundercat)\
**Post date:** [July 18, 2024, 10:28am UTC](https://discourse.processing.org/t/change-icon-in-gwindow-in-g4p/44780/1 "2024-07-18T10:28:23Z")

</div>

Hi Peter,

Was wondering if there’s a way to swap out the GWindow icon on the upper left corner of new GWindows?

Spent a couple hours researching and experimenting before posting here. I found one old post where you gave a hint about it but was unable to implement it. Perhaps your advice on that thread was for an older version of processing.

In any case, is this still possible? I’ve got my app mostly completed in no small part thanks to your incredible support, and I’ve got the main icon for the app switched out, but all the GWindows I’m using show the processing blue arrow instead, which looks tacky.

Ideally I’d even like to be able to suppress that icon, or jury-rig it with a transparent GIF or PNG so there’s no icon there at all, but some level of control would be nice

Thanks for your thoughts.

Mike

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [July 18, 2024, 10:57am UTC](https://discourse.processing.org/t/change-icon-in-gwindow-in-g4p/44780/2 "2024-07-18T10:57:22Z")

</div>

> [@Thundercat](#):
>
> I found one old post where you gave a hint about it but was unable to implement it. Perhaps your advice on that thread was for an older version of processing.

Can’t comment on that post would need to see it.

> [@Thundercat](#):
>
> I’ve got the main icon for the app switched out, but all the GWindows I’m using show the processing blue arrow instead, which looks tacky.

A GWindow is effectively a separate Processing window created on the main sketch thread so the window frame type and therefore decoration depends on the window type

- JAVA2D - JFrame (windowed) control
- P2D/P3D - OpenGL window

We have the secondary complication that these are further dependent on the OS. The image below shows the main sketch window (left) and GWindow (right) from the Mandelbrot example that comes with G4P as presented on an iMac. Notice the lack of border title icon.

 ![Screenshot 2024-07-18 at 11.36.22](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/b/3b3c77d42d91059277abd5b45821766578e92767.png)

I assume you will be exporting your app for Windows, osx and Linux vesrsions in which this will pose problems.

> [@Thundercat](#):
>
> I’ve got the main icon for the app switched out,

It might be possible to apply the same technique for GWindow, how did you do it? Even so it might only be applicable to Windows OS.

---

<div class="post-metadata">

**Author:** ![Thundercat](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Thundercat](https://discourse.processing.org/u/Thundercat)\
**Post date:** [July 18, 2024, 2:56pm UTC](https://discourse.processing.org/t/change-icon-in-gwindow-in-g4p/44780/3 "2024-07-18T14:56:10Z")

</div>

Thank you Peter, helpful as always.

The post was [this one](https://forum.processing.org/two/discussion/21571/changing-the-icon-of-a-g4p-window.html).

The way I changed the app icon itself for Windows on exporting the app for Windows was to use a combination of the following:

1. Declare an image var as global before setup: `PImage appIcon;`
2. Within setup, I added the following, cobbled from other sources. Not sure if the noLoop() is even necessary; haven’t tested extensively:

```auto
noLoop();
appIcon = loadImage("appIcon.png");
surface.setIcon(appIcon);
loop();

```

When exporting the app for Windows x64, it shows the appIcon when you double click it in the upper left corner, and also in the taskbar.

It does not change the windows icon itself - I’m using ResourceHacker or something like that to do that.

But it does not affect the GWindows. I tried using something like this for the GWindows but could never get it working right.

If it worked, I assume a transparent GIF or PNG would show nothing?

In any case, if you have any ideas, I’d be grateful.

Thanks for your time,

Mike

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [July 18, 2024, 3:13pm UTC](https://discourse.processing.org/t/change-icon-in-gwindow-in-g4p/44780/4 "2024-07-18T15:13:47Z")

</div>

> [@Thundercat](#):
>
> ```auto
> appIcon = loadImage("appIcon.png");
> surface.setIcon(appIcon);
> 
> ```

I am not sure what I am going to suggest will work because I use an iMac and as stated previously osx does not seem to display app icons.

At some point you create a window with some statement like this

`window.GWindow.get(...);`

You might try

```auto
window.GWindow.get(...);
PImage appIcon = loadImage("appIcon.png"); // If not already loaded
window.surface.setIcon(appIcon);

```

BTW the `noLoop()` and `loop()` are not needed to change the app icon

---

<div class="post-metadata">

**Author:** ![Thundercat](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Thundercat](https://discourse.processing.org/u/Thundercat)\
**Post date:** [July 18, 2024, 3:30pm UTC](https://discourse.processing.org/t/change-icon-in-gwindow-in-g4p/44780/5 "2024-07-18T15:30:55Z")

</div>

Thank you Peter. I’m on a Mac too - but the app is going to be for Mac, Win, and Linux, so I need to figure out how it will work on the other platforms.

I really appreciate your time.

The appIcon image was already loaded, so I did the following per your suggestion above:

```auto
msgBox = GWindow.getWindow(this, strTitle, width/2 + 120, height/2 + 65, windowWidth, windowHeight, JAVA2D);
msgBox.surface.setIcon(appIcon);

```

But I get an error in the Processing app:

 ![Screenshot 2024-07-18 at 8.29.18 AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/6/4/6481cc1a4146b6e8ecdbd1193cabfee047f53d4c.jpeg)  
 ![Screenshot 2024-07-18 at 8.29.28 AM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/1/b1af967ff256e4d19b5f30b7b03f633e2b7636b3.jpeg)

Maybe there’s another library I need to load?

Thanks for your thoughts.

Mike

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [July 18, 2024, 3:47pm UTC](https://discourse.processing.org/t/change-icon-in-gwindow-in-g4p/44780/6 "2024-07-18T15:47:19Z")

</div>

try

```auto
msgBox.getSurface().setIcon(appIcon);

```

---

<div class="post-metadata">

**Author:** ![Thundercat](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@Thundercat](https://discourse.processing.org/u/Thundercat)\
**Post date:** [July 18, 2024, 5:02pm UTC](https://discourse.processing.org/t/change-icon-in-gwindow-in-g4p/44780/7 "2024-07-18T17:02:46Z")

</div>

> [@quark](#):
>
> `msgBox.getSurface().setIcon(appIcon);`

By George he’s got it! Fan-freaking-tastic!

Not only did it work with the app icon, but I made a transparent PNG and it shows a blank there too! Just what I wanted!

Peter, you’re a national treasure. I really appreciate your brilliance and your support.

Thank you so much!!!

Mike
