Here you can find the source of toHexColor(Color col)
public static String toHexColor(Color col)
//package com.java2s; /*//from w w w . j av a 2 s.com * BioJava development code * * This code may be freely distributed and modified under the * terms of the GNU Lesser General Public Licence. This should * be distributed with the code. If you do not have a copy, * see: * * http://www.gnu.org/copyleft/lesser.html * * Copyright for this code is held jointly by the individual * authors. These should be listed in @author doc comments. * * For more information on the BioJava project and its aims, * or to join the biojava-l mailing list, visit the home page * at: * * http://www.biojava.org/ * * Created on May 20, 2010 * Author: Andreas Prlic * */ import java.awt.*; public class Main { public static String toHexColor(Color col) { return Integer.toHexString((col.getRGB() & 0xffffff) | 0x1000000).substring(1); } }