tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Open Symphony Core > Hex to Color Conversion

Hex to Color Conversion 

OSCore (Open Symphony Core) is a java library with lot of utilities and reusable components. This requires the libraries oscore-2.2.6.jar, mail.jar to be in classpath. The following example shows using TextUtils.hexToColor() API. It converts the given Hex string to Color.

File Name  :  
com/bethecoder/tutorials/oscore/Hex2ColorTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.oscore;

import java.awt.Color;

import com.opensymphony.util.TextUtils;

public class Hex2ColorTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    Color color = TextUtils.hexToColor("#0000ff");
    System.out.println(color);
    
    color = TextUtils.hexToColor("#00ff00");
    System.out.println(color);
    
    color = TextUtils.hexToColor("#808080");
    System.out.println(color);
    
    color = TextUtils.hexToColor("#ffc800");
    System.out.println(color);
  }

}
   

It gives the following output,
java.awt.Color[r=0,g=0,b=255]
java.awt.Color[r=0,g=255,b=0]
java.awt.Color[r=128,g=128,b=128]
java.awt.Color[r=255,g=200,b=0]


                    Print

   



Books Recommendation

 
 
bl  br