<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <br>
    This was implemented in JDK 17 as
    <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8252015">https://bugs.openjdk.org/browse/JDK-8252015</a><br>
    You need to set that property yourself and then ALL your images for
    TrayIcon had better<br>
    all be template images else it will likely look very bad ..<br>
    <br>
    It was done this way to avoid "accidentally" interpretation of
    images as template images<br>
    Personally I wonder if the definition of template images is simple
    and stable we could<br>
    just scan the images to see if they meet the criteria and then mark
    them as template<br>
    images automatically .. but very clearly the developer would need to
    know the rules<br>
    for template images and supply these for mac. There's nothing I can
    think of which<br>
    would allow someone writing a Java app on Windows and not a mac
    aware developer<br>
    to have this magically done for them ...<br>
    <br>
    -phil.<br>
    <br>
    <div class="moz-cite-prefix">On 8/10/22 7:47 AM, Alan Snyder wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:1CD04BA4-65A6-49D4-9482-9C7A350E4D48@cbfiddle.com">
      
      It appears that CTrayIcon has an option to use template images.
      <div class=""><br class="">
      </div>
      <div class="">
        <pre style="background-color: rgb(255, 255, 255); color: rgb(74, 92, 110); font-family: Menlo, monospace; font-size: 9pt;" class=""><span style="color: rgb(130, 157, 112);" class="">apple.awt.enableTemplateImages</span></pre>
        <div class=""><br class="">
        </div>
        <div class="">So, either this option is off or your image does
          not satisfy the rules for template images.</div>
        <div class=""><br class="">
        </div>
        <div class=""><br class="">
        </div>
        <div class=""><br class="">
        </div>
        <div><br class="">
          <blockquote type="cite" class="">
            <div class="">On Aug 10, 2022, at 7:28 AM, Jeremy Wood <<a href="mailto:mickleness@gmail.com" class="moz-txt-link-freetext" moz-do-not-send="true">mickleness@gmail.com</a>>
              wrote:</div>
            <br class="Apple-interchange-newline">
            <div class="">
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">I like that theory,
                thanks. Is it possible to make/assign a template image
                in Java?</div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class=""><br class="">
              </div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">Glancing around just
                now didn’t turn up any leads. Specifically:</div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class=""><br class="">
              </div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">In
                CTrayIcon#updateNativeImage(Image), we call:</div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">CImage.getCreator().createFromImage(image,
                observer)</div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class=""><br class="">
              </div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">… and that method
                appears to convert ‘image’ (a java.awt.Image) into a
                TYPE_INT_ARGB_PRE formatted int array. The word
                “template” isn’t in the CImage class at all. So even if
                I had the imagePtr I don’t see how I can toggle the
                template attribute.</div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class=""><br class="">
              </div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">Regards,</div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class=""> - Jeremy</div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class=""><br class="">
              </div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">------ Original Message
                ------</div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">From "Alan Snyder" <<a href="mailto:javalists@cbfiddle.com" class="moz-txt-link-freetext" moz-do-not-send="true">javalists@cbfiddle.com</a>></div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">To "Jeremy Wood" <<a href="mailto:mickleness@gmail.com" class="moz-txt-link-freetext" moz-do-not-send="true">mickleness@gmail.com</a>></div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">Cc "<a href="mailto:client-libs-dev@openjdk.org" class="moz-txt-link-freetext" moz-do-not-send="true">client-libs-dev@openjdk.org</a>"
                <<a href="mailto:client-libs-dev@openjdk.org" class="moz-txt-link-freetext" moz-do-not-send="true">client-libs-dev@openjdk.org</a>></div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">Date 8/10/2022 8:25:11
                AM</div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">Subject Re: Mac Tray
                Icon Question</div>
              <div style="caret-color: rgb(0, 0, 0); font-family:
                Helvetica; font-size: 12px; font-style: normal;
                font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class=""><br class="">
              </div>
              <div id="x0cf643a2a86446f" style="caret-color: rgb(0, 0,
                0); font-family: Helvetica; font-size: 12px; font-style:
                normal; font-variant-caps: normal; font-weight: 400;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; word-wrap: break-word;
                -webkit-nbsp-mode: space; line-break:
                after-white-space;" class="">
                <blockquote cite="x-msg://3/A481B3B7-1AEC-4B5C-AEF9-92C41F5E8A63@cbfiddle.com" type="cite" class="cite2" style="margin-left: 5px;
                  margin-right: 0px; padding-left: 10px; padding-right:
                  0px; border-left-width: 1px; border-left-style: solid;
                  border-left-color: rgb(204, 204, 204); margin-top:
                  3px; padding-top: 0px;">I suspect the images that work
                  are template images, rather than pairs of images.
                  <div class=""><br class="">
                  </div>
                  <div class="">See <a href="https://developer.apple.com/documentation/appkit/nsimage/1520017-template" class="moz-txt-link-freetext" moz-do-not-send="true">https://developer.apple.com/documentation/appkit/nsimage/1520017-template</a><br class="">
                    <div class=""><br class="">
                    </div>
                    <div class=""><br class="">
                      <div class=""><br class="">
                        <blockquote type="cite" class="">
                          <div class="">On Aug 9, 2022, at 7:12 PM,
                            Jeremy Wood <<a href="mailto:mickleness@gmail.com" class="moz-txt-link-freetext" moz-do-not-send="true">mickleness@gmail.com</a>>
                            wrote:</div>
                          <br class="Apple-interchange-newline">
                          <div class="">
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">On Macs the tray
                              can present black or white icons,
                              depending on the color of the desktop
                              underneath the menubar.</div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><br class="">
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">For example:<br class="">
                              <div class=""><br class="">
                              </div>
                              <div class=""><span id="cid:em82f189d9-daf5-41df-8455-8453732743c6@573fd4be.com" class=""><galpmnvf.png></span></div>
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><br class="">
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><span id="cid:em181f3563-7c90-4e34-9d25-90ace397f75f@573fd4be.com" class=""><qtqoidmn.png></span></div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><br class="">
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">Most icons switch
                              from a black icon to a white icon as
                              needed. A few 3rd party app icons do not
                              switch to a white icon against the black
                              background (for ex: Evernote). And
                              interestingly: Apple’s Airdrop icon (the
                              concentric circles shaped like a sideways
                              pacman) also appears to do the wrong thing
                              too.</div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><br class="">
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">Is there a way in
                              a Java desktop app to set up a tray icon
                              that can toggle between white and black
                              icons as needed?</div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><br class="">
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">Obviously we’d
                              love it if this “just worked” without
                              further intervention by inverting our
                              icon, but we’d also be happy if a solution
                              involved adding a PropertyChangeListener
                              somewhere to identify the menubar change
                              and we could update the tray icons
                              ourselves.</div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><br class="">
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">For ex:</div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">If I change the
                              highlight/accent color (in “System
                              Preferences -> General”), then 8
                              UIManager Colors change (including
                              “textHighlight”, “Button.light”, etc.) as
                              of JDK 18. As far as I can tell: there is
                              no similar model to identify when the
                              menubar changes colors.</div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><br class="">
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">For now we’ve made
                              a work-around by using the Robot class to
                              grab a pixel from the Apple menu icon
                              every few seconds to determine if it’s
                              light or dark.</div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><br class="">
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">Is there an
                              existing way to resolve this we don’t know
                              about?</div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><br class="">
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">Or if not: is
                              anyone reading this with “author” status
                              interested in helping write this up as an
                              openjdk bug?</div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"><br class="">
                            </div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;">Regards,</div>
                            <div class="" style="caret-color: rgb(0, 0,
                              0); font-family: Helvetica; font-size:
                              12px; font-style: normal;
                              font-variant-caps: normal; font-weight:
                              400; letter-spacing: normal; text-align:
                              start; text-indent: 0px; text-transform:
                              none; white-space: normal; word-spacing:
                              0px; -webkit-text-stroke-width: 0px;
                              text-decoration: none;"> - Jeremy</div>
                          </div>
                        </blockquote>
                      </div>
                    </div>
                  </div>
                </blockquote>
              </div>
            </div>
          </blockquote>
        </div>
        <br class="">
      </div>
    </blockquote>
    <br>
  </body>
</html>