473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

an array of the colors in java.awt.color

praclarush
Its been a while since i've writen a java program so I was wondering whats the best way to get an array of the colors in the java.awt.color class. So I can use it to populate a JList. All i'm asking for is a little help in getting started or pointed in the right direction.

Thanks Praclarush
Sep 1 '08 #1
7 7667
Ganon11
3,652 Expert 2GB
Are you talking about the constant colors included in java.awt.Color, or all possible colors?
Sep 1 '08 #2
Are you talking about the constant colors included in java.awt.Color, or all possible colors?
just the constant ones,
Sep 2 '08 #3
Ganon11
3,652 Expert 2GB
it looks like the best way would just be to take the time and type out each constant into your array. You can save some time by copy/pasting the "Color." portion...
Sep 2 '08 #4
JosAH
11,448 Expert 8TB
just the constant ones,
Why not simply use reflection on the Color class then? e.g.

Expand|Select|Wrap|Line Numbers
  1. String name= ...
  2. Color color= (Color)Color.class.getField(name).get();
  3.  
You have to wrap that code snippet in a try ... catch block for obvious reasons.

kind regards,

Jos
Sep 2 '08 #5
BigDaddyLH
1,216 Expert 1GB
Why not simply use reflection on the Color class then? e.g.

Expand|Select|Wrap|Line Numbers
  1. String name= ...
  2. Color color= (Color)Color.class.getField(name).get();
  3.  
You have to wrap that code snippet in a try ... catch block for obvious reasons.

kind regards,

Jos
Sometimes one's behaviour is punishment enough. I hope you like Color.PINK.
Sep 4 '08 #6
JosAH
11,448 Expert 8TB
Sometimes one's behaviour is punishment enough. I hope you like Color.PINK.
That was Zen, a higher state of consciousness and all that.

kind regards,

Jos ;-)
Sep 6 '08 #7
Ya... Thanks for the info sorry I haven't replayed. I've been a little busy.

Praclarush
Sep 6 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: me | last post by:
good day, i found this message: and i want to know more about it too. ========================================== Hey all, example:...
2
by: Tommie Nygren | last post by:
For different reasons I am reading an array of bytes from a file in my ..jar-file and from this I want to create a PNG image using Image.createImage(myArray, 0 , myArray.length). I had a...
15
by: M.Siler | last post by:
<HTML> <HEAD> <TITLE></TITLE> <SCRIPT> <!-- var factor_val = new Array(8,7) factor_val = 68.8 factor_val = 55
47
by: VK | last post by:
Or why I just did myArray = "Computers" but myArray.length is showing 0. What a hey? There is a new trend to treat arrays and hashes as they were some variations of the same thing. But they...
22
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last...
5
by: Brett | last post by:
Sorry for the rookie question.... If I have a pointer array (for example): char *colors = { "blue", "green" }; and I want to add yellow to this array later in my code....how would I do
24
by: RyanTaylor | last post by:
I have a final coming up later this week in my beginning Java class and my prof has decided to give us possible Javascript code we may have to write. Problem is, we didn't really cover JS and what...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
5
by: Stick | last post by:
Hi, I normally program in C++, and I'm trying to write this little tool in C#, but I quickly realized that I can't use pointers, so instead I need to create an array of 3 Color 's private...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.