Swing Flatlaf 自定义属性文件

问题描述 投票:0回答:1

我已通过 Maven 将 flatlaf 外观库集成到我的 Swing 应用程序中,特别是利用 FlatLaf 1.6.2 版本。

在我的应用程序中,我使用了名为“flatlaflight.setup()”的现有主题。但是,在此步骤之前,我在资源目录中引入了一个同名的属性文件。该文件用于根据我的要求定制样式参数。遗憾的是,系统无法检索此属性文件中指定的自定义设置。

将自定义默认源注册到 FlatLightLaf.registerCustomDefaultsSource("src/main/resources"); 也尝试过 FlatLightLaf.registerCustomDefaultsSource("资源");

java maven swing look-and-feel flatlaf
1个回答
0
投票

要在 Maven 项目中使用 FlatLaf 属性文件:

  1. 属性文件名必须与使用的主题类名匹配。例如。
    FlatLightLaf.properties
    代表班级
    FlatLightLaf
    FlatDarkLaf.properties
    代表班级
    FlatDarkLaf
  2. 您必须在BEFORE设置外观之前调用以下方法:
FlatLaf.registerCustomDefaultsSource( "com.myapp.themes" );

其中

com.myapp.themes
是包含您的
.properties
文件的文件夹。

参考

https://www.formdev.com/flatlaf/how-to-customize/#application_properties

© www.soinside.com 2019 - 2024. All rights reserved.