Paul Taylor
Paul Taylor

Reputation: 13140

Java application not using dark title bars even though have implemented NSRequiresAquaSystemAppearance = False

I have implemented a Dark Mode for my Java application (using flatlaf) but the title bar has light appearance even when MacOS itself it set to use Dark Mode. The possible solution is to set NSRequiresAquaSystemAppearance to false in the Info.plist file. I have done this as part of building the appbundle (with TheInfiniteKind fork of appbundler) but it is not working for me

This is the contents of the generated Info.plist file

<?xml version="1.0" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>SongKong</string>
<key>CFBundleIconFile</key>
<string>songkong.icns</string>
<key>CFBundleIdentifier</key>
<string>com.jthink.songkong</string>
<key>CFBundleDisplayName</key>
<string>SongKong</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>SongKong</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>8.2</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleHelpBookFolder</key>
<string>SongKongHelp</string>
<key>CFBundleHelpBookName</key>
<string>com.jthink.songkong.Help</string>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>CFBundleSignature</key>
<string>sgkg</string>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>LSMinimumSystemVersion</key>
<string>10.7</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.music</string>
<key>LSUIElement</key>
<false/>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>IgnorePSN</key>
<false/>
<key>NSRequiresAquaSystemAppearance</key>
<false/>
<key>JVMRuntime</key>
<string>temurin-17.jdk</string>
<key>JREPreferred</key>
<false/>
<key>JDKPreferred</key>
<false/>
<key>JVMMainClassName</key>
<string>com.jthink.songkong.cmdline.SongKong</string>
<key>JVMDebug</key>
<false/>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>mp3</string>
<string>wma</string>
<string>ogg</string>
<string>flac</string>
<string>wav</string>
<string>aif</string>
<string>aiff</string>
<string>aifc</string>
</array>
<key>LSTypeIsPackage</key>
<false/>
<key>CFBundleTypeName</key>
<string>Music Files</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
</array>
<key>LSArchitecturePriority</key>
<array>
</array>
<key>LSEnvironment</key>
<dict>
<key>LC_CTYPE</key>
<string>UTF-8</string>
</dict>
<key>JVMOptions</key>
<array>
<string>-Dcom.mchange.v2.log.MLog=com.mchange.v2.log.jdk14logging.Jdk14MLog</string>
<string>-Dorg.jboss.logging.provider=jdk</string>
<string>-Djava.util.logging.config.class=com.jthink.songkong.logging.StandardLogging</string>
<string>-Dapple.laf.useScreenMenuBar=true</string>
<string>-Dapple.awt.brushMetalLook=true</string>
<string>-Dsun.java2d.metal=true</string>
<string>-XX:+HeapDumpOnOutOfMemoryError</string>
</array>
<key>JVMDefaultOptions</key>
<dict>
</dict>
<key>JVMArguments</key>
<array>
</array>
<key>NSRequiresAquaSystemAppearance</key>
<false/>
<key>AppleWindowTabbingMode</key>
<string>manual</string>
</dict>
</plist>

Upvotes: 2

Views: 633

Answers (1)

Paul Taylor
Paul Taylor

Reputation: 13140

Things seem to have moved on, I found this issue fixed in Java 14 - https://bugs.openjdk.java.net/browse/JDK-8235363

I found setting

-Dapple.awt.application.appearance=system

as an element in JVMOptions in the Info.plist worked as expected.

Upvotes: 1

Related Questions