Java Nimbus 外观和感觉 RSyntaxTextArea 背景颜色

Java Nimbus Look & Feel RSyntaxTextArea Background Color

我正在使用最终从 JTextArea 扩展而来的 RSyntaxTextArea。当我将外观更改为 Nimbus 时,文本区域不会像 GUI 的其余部分那样受到影响,后者看起来不太好。

这是我使用的Nimbus主题代码:

import javax.swing.*;
import java.awt.*;

import static javax.swing.SwingUtilities.updateComponentTreeUI;
import static javax.swing.UIManager.*;

public class SwingLookAndFeel
{
    static void setDarkNimbusLookAndFeel(JFrame frame) throws Exception
    {
        put("control", new Color(128, 128, 128));
        put("info", new Color(128, 128, 128));
        put("nimbusBase", new Color(18, 30, 49));
        put("nimbusAlertYellow", new Color(248, 187, 0));
        put("nimbusDisabledText", new Color(128, 128, 128));
        put("nimbusFocus", new Color(115, 164, 209));
        put("nimbusGreen", new Color(176, 179, 50));
        put("nimbusInfoBlue", new Color(66, 139, 221));
        put("nimbusLightBackground", new Color(18, 30, 49));
        put("nimbusOrange", new Color(191, 98, 4));
        put("nimbusRed", new Color(169, 46, 34));
        put("nimbusSelectedText", new Color(255, 255, 255));
        put("nimbusSelectionBackground", new Color(104, 93, 156));
        put("text", new Color(230, 230, 230));

        for (LookAndFeelInfo[] info : getInstalledLookAndFeels())
        {
            if ("Nimbus".equals(info.getName()))
            {
                setLookAndFeel(info.getClassName());
                break;
            }
        }

        refreshFrame(frame);
    }

    private static void refreshFrame(JFrame frame)
    {
        if (frame != null)
        {
            updateComponentTreeUI(frame);
            // frame.pack();
        }
    }
}

我想知道修改文本区域背景颜色需要哪些 UIManager 键,例如将左侧 JTree 中的紫色设置为背景色而不是白色?

Here 是我找到的 UIManager 个键的列表,但在这种情况下它们中的任何一个甚至有用吗?

Here 描述了如何使用专门针对 RSyntaxTextArea 的主题。使用提供的 dark.xml 工作正常:

private void changeStyleViaThemeXml() {
  try {
     Theme theme = Theme.load(getClass().getResourceAsStream(
           "/org/fife/ui/rsyntaxtextarea/themes/dark.xml"));
     theme.apply(textArea);
  } catch (IOException ioe) { // Never happens
     ioe.printStackTrace();
  }
}