⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e584. retrieving a predefined color by name.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
The Color class contains a number of predefined colors such as red and green. This example demonstrates how to retrieve one of these predefined colors using a string. For example, the predefined color java.awt.Color.red could be retrieved with the string "red". 
    // Returns a Color based on 'colorName' which must be one of the predefined colors in
    // java.awt.Color. Returns null if colorName is not valid.
    public Color getColor(String colorName) {
        try {
            // Find the field and value of colorName
            Field field = Class.forName("java.awt.Color").getField(colorName);
            return (Color)field.get(null);
        } catch (Exception e) {
            return null;
        }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -