Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.Color;

public class Main {
    /**
     * Retrieve and transform the property value into a Color.
     * @param name The property name
     * @return The corresponding color
     */
    public static Color asColor(String color) {
        if (color != null) {
            String[] rgb = color.split(",");
            if (rgb.length == 3) {
                try {
                    return new Color(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2]));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
}