# Mac - red close window dot - how set modified?

**URL:** <https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970>\
**Category:** Coding Questions\
**Created:** [December 1, 2022, 6:03pm UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970 "2022-12-01T18:03:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Svedblen](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@Svedblen](https://discourse.processing.org/u/Svedblen)\
**Post date:** [December 1, 2022, 6:03pm UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/1 "2022-12-01T18:03:25Z")

</div>

Hi,

I’m running (Java) Processing on a Mac and I would like to be able to set the black tiny dot inside the red Close Window dot when my application is “modified”. Any ideas on how to manage that?

Thanks

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [December 1, 2022, 6:32pm UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/2 "2022-12-01T18:32:36Z")

</div>

Hello @Svedblen 🙂

Can you share more details and explain what exactly you are trying to accomplish? Thanks!

---

<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:** [December 1, 2022, 6:52pm UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/3 "2022-12-01T18:52:44Z")

</div>

The application window frame, including the red, amber and green dots are managed by macOS and not the Processing IDE. I would expect it would be difficult to do what you want from inside Processing.

Personally I have no idea how you might achieve your objective.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 1, 2022, 7:32pm UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/4 "2022-12-01T19:32:15Z")

</div>

Hi @Svedblen,

Can’t test, but you can try …

Cheers  
— mnse

```auto
import javax.swing.*;
import processing.awt.*;

JFrame frame;

void setup() {
   frame=(JFrame) ((PSurfaceAWT.SmoothCanvas)getSurface().getNative()).getFrame();
}

void mousePressed () { 
   frame.getRootPane().putClientProperty("windowModified",true)
}

void draw() {
   background(128);
}

```

PS: @sableraph: guess he mean to set the window to dirty state…

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [December 1, 2022, 8:12pm UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/5 "2022-12-01T20:12:52Z")

</div>

Aaaah I guess you’re right!

I tried your code on macOS Monterey and it doesn’t seem to work 🤔

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/1/5/1593ad2e4d49680e8c95b405c8298ea34775f59a.jpeg)

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 1, 2022, 8:30pm UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/6 "2022-12-01T20:30:55Z")

</div>

Hi @sableraph,

Would you please try again with: `"JComponent.windowModified"`

And maybe also set to `Boolean.TRUE`.

So in length:

frame.getRootPane().putClientProperty(“JComponent.windowModified”,Boolean.TRUE);

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![Svedblen](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@Svedblen](https://discourse.processing.org/u/Svedblen)\
**Post date:** [December 1, 2022, 8:31pm UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/7 "2022-12-01T20:31:03Z")

</div>

Thanks @mnse, I tested it, but as @sableraph said it does not work. It compiles and it runs but the red dot is unaffected.

Sorry, “JComponent.windowModified” does not do it either.

---

<div class="post-metadata">

**Author:** ![Svedblen](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@Svedblen](https://discourse.processing.org/u/Svedblen)\
**Post date:** [December 1, 2022, 8:38pm UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/8 "2022-12-01T20:38:18Z")

</div>

@sableraph, as for what I’m trying to accomplish. I have a sketch where some data, read from a file, is shown to the user. The user can modify that data and if he/she does I want the red dot to indicate “unsaved” data, which the user preferable should save before exiting. As per normal for a Mac application.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 1, 2022, 8:51pm UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/9 "2022-12-01T20:51:05Z")

</div>

Hi,

As said, can’t test further. Traced several java code for MacOs which doing it exactly that way !?  
Maybe one with a Mac can do further analysis…

Sorry and Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 2, 2022, 6:45am UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/10 "2022-12-02T06:45:44Z")

</div>

Hi @Svedblen,

Ok! One last try …

_Found on the [processing source](https://github.com/processing/processing4/blob/1b137e27c6f8af36df4946d6b58e9fc49fbcbe8d/app/src/processing/app/Sketch.java#L780) itself, after I’ve spotted the black dot in the image posted by @sableraph, where the PDE shows it_ … 🙂

`frame.getRootPane().putClientProperty("Window.documentModified", Boolean.TRUE);`

Cheers  
— mnse

PS:

> **[Technical Note TN2196: New Control Styles available within J2SE 5.0 on Mac OS...](https://developer.apple.com/library/archive/technotes/tn2007/tn2196.html#WINDOW_DOCUMENTMODIFIED)**
>
> TN2196: Details what new control styles are available within J2SE 5.0 on Mac OS X 10.5

PPS: Also to set it with a Boolean Object is important.

> **[Technical Q&A QA1146: Illustrating document window changes in Swing](https://web.archive.org/web/20100523195925/http://developer.apple.com/mac/library/qa/qa2001/qa1146.html)**
>
> Technical Q&A QA1146: Use the Aqua close button dot to indicate
> your documents have changed.

---

<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:** [December 2, 2022, 9:00am UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/11 "2022-12-02T09:00:07Z")

</div>

Well done @mnse your perseverance has paid off and it worked on my mac. 😄

Just out of interest do you know what effect this has in Windows and Linux?

---

<div class="post-metadata">

**Author:** ![Svedblen](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@Svedblen](https://discourse.processing.org/u/Svedblen)\
**Post date:** [December 2, 2022, 10:48am UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/12 "2022-12-02T10:48:56Z")

</div>

Great work @mnse! It works like a charm! Thanks a lot.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [December 2, 2022, 11:38am UTC](https://discourse.processing.org/t/mac-red-close-window-dot-how-set-modified/39970/13 "2022-12-02T11:38:00Z")

</div>

Hi,

lucky to helped ! 🤓

> [@quark](#):
>
> Just out of interest do you know what effect this has in Windows and Linux?

@quark: Guess none! Looks very mac specific… 🙂

Cheers  
— mnse
