FileDocCategorySizeDatePackage
ColorName.javaAPI DocExample1729Sat Nov 25 12:54:10 GMT 2000None

ColorName

public class ColorName extends Object
A simple class for looking up Java AWT Color Names; I got tired of including this code in every Applet that needed it! (yes, this IS a hint to JavaSoft.).
author
Ian Darwin, delinted by Bill Heinze

Fields Summary
protected static ColorNameMap[]
map
The list of known color names and their corresponding colors
Constructors Summary
Methods Summary
public static java.awt.Colorlookup(java.lang.String c)
Lookup a given string

returns
The java.awt.Color corresponding, or null.


	     	    	 
	     
		if (c == null)
			return null;
		if (c.charAt(0) == '#")			// hex encoding
			return Color.decode(c);
		for (int i=0; i<map.length; i++)
			if (c.equalsIgnoreCase(map[i].color))
				return map[i].jColor;
		return null;
	
public static voidmain(java.lang.String[] a)
Just a test

		test("WhItE");
		test("Ucky Purple Pink Spots");
		test(null);
		test("#c0d0e0");
	
public static voidtest(java.lang.String s)

		System.out.println('"" + s + '"" + " returns " + ColorName.lookup(s));