vaery basic Java Color class question

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2008
Posts: 102
Reputation: localp is an unknown quantity at this point 
Solved Threads: 2
localp localp is offline Offline
Junior Poster

vaery basic Java Color class question

 
0
  #1
Nov 17th, 2008
can some one help me write a program, that works when passing 3 values (r g b value), to a Color class and outputs its corresponding colour..

please help me by giving a sample code and the output ...
Local P ...
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: vaery basic Java Color class question

 
0
  #2
Nov 17th, 2008
Originally Posted by localp View Post
please help me by giving a sample code and the output ...
please help us by showing what you've tried so far
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 102
Reputation: localp is an unknown quantity at this point 
Solved Threads: 2
localp localp is offline Offline
Junior Poster

Re: vaery basic Java Color class question

 
0
  #3
Nov 17th, 2008
  1. int r=245;
  2. int g = 90;
  3. int b =78;
  4.  
  5. Color c = new Color(r,g,b);
  6.  
  7. c. // <<--- then i dont know what methos to call
  8.  
  9. //and i am not sure how to display the colour
i am a beginner !
Last edited by localp; Nov 17th, 2008 at 5:41 am.
Local P ...
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: vaery basic Java Color class question

 
0
  #4
Nov 17th, 2008
I don't totally get what you 're trying to do, but this would be a good place to start looking:
http://java.sun.com/j2se/1.4.2/docs/...awt/Color.html
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 102
Reputation: localp is an unknown quantity at this point 
Solved Threads: 2
localp localp is offline Offline
Junior Poster

Re: vaery basic Java Color class question

 
0
  #5
Nov 17th, 2008
Originally Posted by stultuske View Post
I don't totally get what you 're trying to do, but this would be a good place to start looking:
http://java.sun.com/j2se/1.4.2/docs/...awt/Color.html
this is what i am trying to do,,, i am trying to pass 3 int values in to the Color constructor...
and i want to see the correspoding colour of the integer to display ...

example if we pass 255 0 0, we should see the colour RED visible as output
Local P ...
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,479
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 514
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: vaery basic Java Color class question

 
0
  #6
Nov 17th, 2008
Assuming this is in a GUI, set the background color of one of your components to that color. You could create a JLabel for that purpose, or just use the background of your existing frame/panel.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC