Java Nimbus Look&感觉RSyntaxTextArea背景颜色

时间:2018-01-04 23:35:30

标签: java swing look-and-feel nimbus rsyntaxtextarea

我使用的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的紫色设置为背景颜色而不是白色?

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

1 个答案:

答案 0 :(得分:0)

Here描述了如何专门为<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>13.15</title> </head> <body> <form method="post"> fruit: <input type="text" name="fruit"><br><br> <input type="submit" name="add" value="add"><br><br> -------------------------<br><br> <input type="submit" name="sort" value="sort"> <input type="submit" name="shuffle" value="'shuffle'"><br><br> ------------------------- <br><br> </form> <?php session_start(); if (!isset($_SESSION['fruit'])) $_SESSION['fruit'] = array("Pear", "Apple", "Orange"); $fruit = $_SESSION['fruit']; if(isset($_POST['add'])) { array_push($fruit, $_POST['fruit']); $_SESSION['fruit'] = $fruit; } if(isset($_POST['sort'])) { sort($fruit); foreach ($fruit as $key => $val) { echo "- " . $val . "<br />" . "\n"; } } if(isset($_POST['shuffle'])) { shuffle($fruit); foreach ($fruit as $key => $val) { echo "- " . $val . "<br />" . "\n"; } } ?> </body> </html> 使用主题。使用提供的RSyntaxTextArea可以正常工作:

dark.xml