我正在使用RSyntaxTextArea
最终从JTextArea
. 当我将外观更改为 时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
左侧的紫色设置为背景颜色而不是白色?
这是UIManager
我找到的键列表,但它们中的任何一个在这种情况下甚至有用吗?