code: public void setHex(String hex) throws Exception {
  
          if (hex.length() == 6) {
              setRGB(
                  Integer.parseInt(hex.substring(0, 2), 16),
                  Integer.parseInt(hex.substring(2, 4), 16),
                  Integer.parseInt(hex.substring(4, 6), 16));
          } else if (hex.length() == 3) {
              setRGB(
                  Integer.parseInt(hex.substring(0, 1), 16),
                  Integer.parseInt(hex.substring(1, 2), 16),
                  Integer.parseInt(hex.substring(2, 3), 16));
          } else {
              setRGB(255, 255, 255);
          }
      }
docs: Sets the hexadecimal representation of Red, Green and Blue.<p>
  @param hex The hexadecimal string notation. It must be 6 or 3 letters long and consist of the characters 0-9 and A-F
  @throws java.lang.Exception if something goes wrong