Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it possible to get a light-blue color?

 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ever-helping ranchers,
In my application I want to use light-blue color.
Color.blue always gives a darker version of the color.
How to get & use light-blue color?
Throw some light on this?
Regards
 
Maneesh Godbole
Saloon Keeper
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you take a look at the Color API? I am sure there must be methods to make a color darker (hint) or brighter(hint).
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks manish for your observations, but still the challenge is not succeeded.


Some error trace :


I'm not worried about the others.
If somebody could help me in getting that lightblue color I would be happy.
Regards
 
Maneesh Godbole
Saloon Keeper
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exceptions are generated because you are trying access the System resources from an unsigned applet.
Why are you trying to print it out? I mean you can see it on the screen right?
 
Maneesh Godbole
Saloon Keeper
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.
Lets get it over and done with.
Use something like
or
The API will give you information on what the 4 parameters mean.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is working fine.
While the other when I tried it with


was not working fine.

But anyhow thanks for the information maneesh.
Meanwhile how did you know of the parameters
new Color(0,0,182,155)

Regards
 
Omar Nasir
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ramya,



found in the site :

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Color.html


i hope this helps.

Regards,

Omar
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And to get the rgb values of a Color that you want, use a Color Picker.
Or try it out on MS Paint or even Word.
 
Maneesh Godbole
Saloon Keeper
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ramya narayanan wrote:
Meanwhile how did you know of the parameters
new Color(0,0,182,155)


Because unlike you, I read the whole API carefully (Just kidding)
It is just one of the things you tend to pick up, playing around with stuff. Ever wanted to make over transparent UI components? Then the 'alpha' is your friend.

One interesting point with the brighter.
It is perfectly legal to do this until you are satisfied.


 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Helping ranchers,
First of all my humble thanks to all maneesh, sridhar & others who have shared their expertise & made my job easier.

And to get the rgb values of a Color that you want, use a Color Picker.
Or try it out on MS Paint or even Word.


1) How to get that rgb values using that?

2) Also when I went through the API there are two constructors with & without alpha value.
What is this alpha value & what is its significance?

Regards
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ever-helping ranchers,

But this is not changing into lightblue color which I want.
Regards
 
Campbell Ritchie
Sheriff
Pie
Posts: 49788
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh has told you what "alpha" means, and there is more about it in the Color class.

This looks like a GUI-related thread, so it would be more appropriate for the Swing forum. Moving.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12185
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API page for the Color class:

The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary color spaces identified by a ColorSpace. Every color has an implicit alpha value of 1.0 or an explicit one provided in the constructor. The alpha value defines the transparency of a color and can be represented by a float value in the range 0.0 - 1.0 or 0 - 255. An alpha value of 1.0 or 255 means that the color is completely opaque and an alpha value of 0 or 0.0 means that the color is completely transparent. When constructing a Color with an explicit alpha or getting the color/alpha components of a Color, the color components are never premultiplied by the alpha component.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at this color picker. Once you have the color code you want, change the hex code (#XXXXXX) to RGB values. The first two is Red, The next two Green and last two Blue.

Or better there must be some color picker which gives you directly RGB values.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Word - > Font Color -> more colors -> Custom-> select the color and get the RGB values.

Hope this helps.
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//tried a bit, might require some more work, blue shade of the label changes based on alpha value
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic