Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2005

Tip: Looking for answers? Try searching our database.

ColorSpace

Thread view: 
Frances - 10 Oct 2005 01:02 GMT
pls any Color Space defined here
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/color/ColorSpace.html

is HEX?  (for example, instead of

      Color bgColor = new Color(233,233,233);

I would like to be able to do

    Color bgColor = new Color(E9E9E9);

I'm trying to pass color values from an html file to embedded applet,
but am finding this a bit trickier than I thought given that (I assume)
you can only pass string literals from HTML to applet, and these color
values are not string literals (is E9E9E9 a string literal?  now that I
think about it, I don't know.....;) i.e., is it

    Color bgColor = new Color("E9E9E9");
  (probably not....;)

I just thought passing HEX values might be simpler than passing RGB
values (b/c if you pass RGB values, you're passing three diff. values,
i.e., three diff. integers (if I read the docs right..)
also it would be much easier to copy color value from PhotoShop in HEX,
you just copy value in field where HEX value appears in Color Picker,
RGB values are each in a separate field, and that's kind of a pain...
this color thing in doing java interfaces has turned out to be a bit of
pain b/c of these issues...)  would appreciate suggestions here..

thank you,
Frances

    
Andrey Kuznetsov - 10 Oct 2005 02:11 GMT
> Color bgColor = new Color("E9E9E9");

int rgb = Integer.parseInt("E9E9E9", 16);
Color c = new Color(rgb);

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Thomas Fritsch - 10 Oct 2005 02:16 GMT
> pls any Color Space defined here
> http://java.sun.com/j2se/1.4.2/docs/api/java/awt/color/ColorSpace.html
Why do write ColorSpace here? Your whole post below is about Color, not
ColorSpace.
<http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html>

> is HEX?  (for example, instead of
>
[quoted text clipped - 3 lines]
>
> Color bgColor = new Color(E9E9E9);

> I'm trying to pass color values from an html file to embedded applet, but
> am finding this a bit trickier than I thought given that (I assume) you
[quoted text clipped - 4 lines]
> Color bgColor = new Color("E9E9E9");
>   (probably not....;)

Color has a constructor that understands
Color bgColor = new Color(0xE9E9E9);
See <http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html#Color(int)>
So all you have to figure out, is how to convert String a "E9E9E9" to an int
0xE9E9E9. Look at java.lang.Integer!

[...]
Roedy Green - 11 Oct 2005 07:30 GMT
>    Color bgColor = new Color(E9E9E9);

there is a constructor new Color (0xe9e9e9);
also new Color ( 0xe9, 0xe9, 0xe9 );
or new Color ( someInt );
when someInt's value  started out life as a decimal literal, hex
literal, hex string, decimal string...

see http://mindprod.com/gloss/hex.html#HEXCOLOR

note Sun's docs for the alpha channel constructor are misleading. Read
them carefully.  I have a documentation bug report in.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Frances Del Rio - 25 Oct 2005 15:44 GMT
>>    Color bgColor = new Color(E9E9E9);
>
[quoted text clipped - 8 lines]
> note Sun's docs for the alpha channel constructor are misleading. Read
> them carefully.  I have a documentation bug report in.

thank you all so much..  had not had time to deal w/this until now..
now I have my system to set colors in HTML where applet is embedded..
and in applet process thus:

Color bgClr = new Color(Integer.parseInt(getParameter("bgClr"), 16));

now I don't have to compile applet every time I change a color.....:)

Frances


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.