public static String colorToString (final Color c)
    {
      try {
          final Field[] fields = Color.class.getFields();
          for (final Field f : fields) {
              if (Modifier.isPublic(f.getModifiers())
                      && Modifier.isFinal(f.getModifiers())
                      && Modifier.isStatic(f.getModifiers())) {
                  final String name = f.getName();
                  final Object oColor = f.get(null);
                  if (oColor instanceof Color) {
                      if (c.equals(oColor)) {
                          return name;
                      }
                  }
              }
          }
      }
      catch (Exception e) {
          //
      }

      // no defined constant color, so this must be a user defined color
      final String color = Integer.toHexString(c.getRGB() & 0x00ffffff);
      final StringBuffer retval = new StringBuffer(7);
      retval.append("#");

      final int fillUp = 6 - color.length();
      for (int i = 0; i < fillUp; i++) {
          retval.append("0");
      }

      retval.append(color);
      return retval.toString();
    }