Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import org.w3c.dom.Element;

public class Main {
    private static final String TAG_NAME_BLUE = "blue";
    private static final String TAG_NAME_GREEN = "green";
    private static final String TAG_NAME_RED = "red";

    /**
     * Constructs a rgb value from given document
     * @param elem
     * @return
     */
    public static Color getRGB(Element elem) {
        int r = Integer.parseInt(elem.getElementsByTagName(TAG_NAME_RED).item(0).getTextContent());
        int g = Integer.parseInt(elem.getElementsByTagName(TAG_NAME_GREEN).item(0).getTextContent());
        int b = Integer.parseInt(elem.getElementsByTagName(TAG_NAME_BLUE).item(0).getTextContent());
        return new Color(r, g, b);

    }
}