Java 即使实现了 NSRequiresAquaSystemAppearance = False,应用程序也不使用深色标题栏

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

我已经为我的 Java 应用程序(使用 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)实现了深色模式,但它对我不起作用

这是生成的Info.plist文件的内容

<?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>

事情似乎有所进展,我发现此问题已在 Java 14 - https://bugs.openjdk.java.net/browse/JDK-8235363

中修复

我找到了设置

-Dapple.awt.application.appearance=system

作为 JVMOptions 中的一个元素,在 Info.plist 中按预期工作。