static String colorToHex(Color color){
  String colorstr="#";
  String str=Integer.toHexString(color.getRed());
  if (str.length() > 2)   str=str.substring(0,2);
 else   if (str.length() < 2)   colorstr+="0" + str;
 else   colorstr+=str;
  str=Integer.toHexString(color.getGreen());
  if (str.length() > 2)   str=str.substring(0,2);
 else   if (str.length() < 2)   colorstr+="0" + str;
 else   colorstr+=str;
  str=Integer.toHexString(color.getBlue());
  if (str.length() > 2)   str=str.substring(0,2);
 else   if (str.length() < 2)   colorstr+="0" + str;
 else   colorstr+=str;
  return colorstr;
}

static String colorToHex ( Color color ) { String colorstr = "#" ; String str = Integer . toHexString ( color . getRed ( ) ) ; if ( str . length ( ) > 2 ) str = str . substring ( 0 , 2 ) ; else if ( str . length ( ) < 2 ) colorstr += "0" + str ; else colorstr += str ; str = Integer . toHexString ( color . getGreen ( ) ) ; if ( str . length ( ) > 2 ) str = str . substring ( 0 , 2 ) ; else if ( str . length ( ) < 2 ) colorstr += "0" + str ; else colorstr += str ; str = Integer . toHexString ( color . getBlue ( ) ) ; if ( str . length ( ) > 2 ) str = str . substring ( 0 , 2 ) ; else if ( str . length ( ) < 2 ) colorstr += "0" + str ; else colorstr += str ; return colorstr ; }
converts a type color to a hex string in the format " # rrggbb "
