【问题标题】:Customize theme color in Flatlaf Look and Feel在 Flatlaf 外观和感觉中自定义主题颜色
【发布时间】:2021-08-06 18:16:55
【问题描述】:

我在 Java swing 中为我的 GUI 使用 Flatlaf 外观。我导入了 Flatlaf 中的预制主题,但我想稍微更改配色方案中的一种颜色。它是用于突出显示 JComponents 和选定选项卡的颜色。有没有办法做到这一点?

自定义 L&F 的标准方法是:

try {
        UIManager.setLookAndFeel(new FlatSolarizedLightIJTheme());
        UIManager.put("choose JComponent here","choose value here");

} catch( Exception ex ) { 
}

【问题讨论】:

标签: java swing background look-and-feel jcomponent


【解决方案1】:

我不知道如何在 FlatLaf 中执行此操作,但是还有另一个名为 material-ui-swing 的库可以让您更强大地处理材质主题,然后是与 UIManager 一起使用的库。

你可以这样做:

  try {
      JDialog.setDefaultLookAndFeelDecorated(true);
      JFrame.setDefaultLookAndFeelDecorated(false);
      MaterialTheme theme = new MaterialLiteTheme();
      // here your custom config theme.setXXX();
      MaterialLookAndFeel material = new MaterialLookAndFeel(theme);
      UIManager.setLookAndFeel(material);
  } catch (UnsupportedLookAndFeelException e) {
      e.printStackTrace();
  }

在 MaterialTheme 上,您可以调用以下 API https://vincenzopalazzo.github.io/material-ui-swing 来更改任何类型的颜色,或将自定义主题作为外部库实现为以下主题 DarkStackOverflowTheme

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-10
    • 2018-06-14
    • 2011-06-17
    • 2021-12-16
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多