views:

85

answers:

7
add(new CustomLabelField
("Please enter your credentials:", Color.WHITE, 0x999966, 0));

What is that 0x999966?

I want to place this color there so how can I convert it? I just need an online tool that will convert it for me but I don't even know what it's called! :D

link for more info

Thanks!

Edit: OK, so this is called a hexadecimal number, but I still don't know how to convert something like "#716eb3" to the notation accepted by the CustomLabelField constructor. Any help?

+3  A: 

Hexadecimal, as in, base 16. If 0x999966 is indicating a color, then it's usually encoded such that each two hex digits encode a color (as RGB), so it's 0xRRGGBB.

Gian
I thought this was hexadecimal? #716eb3.
Serg
That notation is non-standard and is only used by HTML and related tools, AFAIK. 0x... is much more common in programming and computer science. In either case, both are valid hex numbers.
Gian
`0x` or `#` as a prefix is just a convention to distinguish between hexadecimal and decimal (after all, it's only about conventions). This depends on the language. Some languages (typically, assembly) would use `999966h` for example. `0x` tends to be the notation used in *C* for example, whereas `#` would be used in *CSS* for colours.
Bruno
To answer your other question, #716eb3 is exactly equivalent to 0x716eb3.
Gian
Thanks. :D (padding to 15)
Serg
A: 

Thats a number in base 16 or hexadecimal number.

codaddict
Isn't this hexadecimal? #716eb3 - how can I convert this #716eb3 to something like the code above?
Serg
+1  A: 

Looks like a hexadecimal representation of a RGB. For example with #716eb3:

add(new CustomLabelField
("Please enter your credentials:", Color.WHITE, 0x716eb3, 0));
Darin Dimitrov
+1  A: 

That's the hexadecimal notation for a RGB color.

Google has a list of online converters that might interest you.

Vivien Barousse
A: 

It looks like it might be in Java.

First, take the substring to remove the # prefix, then use Integer.parseInt("9999966", 16): that's parseInt with the radix for the base (see Integer documentation). Something along these lines:

String colour = "#716eb3";
colour = colour.substring(1,colour.length()-1);
add(new CustomLabelField ("Please enter your credentials:",
     Color.WHITE, Integer.parseInt(colour,16), 0));
Bruno
Note that this is only if you need to read the value dynamically, perhaps from a configuration file. If you want to hard-code the value, use `0x716eb3` directly, as others have already suggested.
Bruno
A: 
  1. In many programming languages, numbers prefixed with 0 are octal and with 0x are hexadecimal.

  2. Search for Hexadecimal to Decimal or Hexadecimal to RGB converters.

dheerosaur
A: 

If it's C#, the format expected by the CustomLabelField constructor is most likely System.Drawing.Color that uses the ARGB format.

“The color of each pixel is represented as a 32-bit number: 8 bits each for alpha, red, green, and blue (ARGB). The alpha component specifies the transparency of the color: 0 is fully transparent, and 255 is fully opaque. Likewise, an A value of 255 represents an opaque color. An A value from 1 through 254 represents a semitransparent color. The color becomes more opaque as A approaches 255.”

Converting the ARGB format into a System.Drawing.Color can be done as follows:

Color myColor = ColorTranslator.FromHtml("#FF999966");
Dave M