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



我已经为我的Java应用程序实现了黑暗模式(使用flatlaf(,但即使MacOS本身设置为使用黑暗模式,标题栏也会很亮。可能的解决方案是在Info.plist文件中将NSRequiresAquaSystemAppearance设置为false。我这样做是作为构建appbundle的一部分(使用appbundler的TheInfiniteKind分支(,但它对我不起作用

这是生成的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>

事情似乎有所进展,我发现这个问题在Java14-https://bugs.openjdk.java.net/browse/JDK-8235363

我发现设置

-Dapple.awt.application.appearance=system

作为Info.plistJVMOptions的一个元素,工作正常。

最新更新