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 / February 2004

Tip: Looking for answers? Try searching our database.

color tool

Thread view: 
The Chief - 05 Feb 2004 07:14 GMT
+-----------------------+
|+--------------------+    |
||                    | |
||  fill with color   |    |
||                    | |
||                    | |
|+--------------------+ |
| Hex Value [#xxxxxx]    |
| Red:   -----|-------    |
| Green: -----|-------    |
| Blue:  -----|-------    |
+-----------------------+

That's basically what I want to do. I hope the sketch above came out
well. Here's a description - just in case. I want to make a simple app
that will have three JSliders that will represent RGB (red, green,
blue). Also I want the hex value of the current color to be printed in a
text field or something like that (so that it could be easily copied).
Basically, I think i can do everything but I have no idea on how to
compute the HEX values of a color. Or how to "bind" the JSliders with
the hex value computing. I know this is actually the whole program but
any help would be greatly appreciated.

I'm newbie and still exploring the depths of Java. :)

Thanks in advance! :)
Thomas Weidenfeller - 05 Feb 2004 08:00 GMT
> That's basically what I want to do. I hope the sketch above came out
> well. Here's a description - just in case. I want to make a simple app
[quoted text clipped - 5 lines]
> the hex value computing. I know this is actually the whole program but
> any help would be greatly appreciated.

You want to explore javax.swing.JColorChooser first, before running your
own.

/Thomas
Knute Johnson - 05 Feb 2004 18:14 GMT
>> That's basically what I want to do. I hope the sketch above came out
>> well. Here's a description - just in case. I want to make a simple app
[quoted text clipped - 10 lines]
>
> /Thomas

Thomas:

You will only need hex numbers if you want to display the color values
in hex.  It is very easy to convert an int to a hex string.

String Integer.toString(int i, int radix);

This sounds like a fun programming exercise even if there already is a
really nice built in tool (JColorChooser) to do the job.  Why don't you
start writing it and post your progress and any question?

knute...
email s/nospam/knute/
The Chief - 05 Feb 2004 21:29 GMT
Thank you for the responses. Here's what I've done today. I wrote the
app - basically, JFrame, JPanel, 3 JSliders - pretty simple. I can
successfully show the color by moving the sliders - at first i didn't
know how to do that but i did some googling and that helped a lot. I
made an inner class ColorListener that implements the ChangeListener
class. I'll post the code later, i don't have it on this computer yet.

> You will only need hex numbers if you want to display the color values
> in hex.  It is very easy to convert an int to a hex string.
>
> String Integer.toString(int i, int radix);

That's exactly what I want to do. I want to add a little JTextArea and
print the color hex value in there. (The purpose is to make the app
useful for web page designing - get the color value easily).

> This sounds like a fun programming exercise even if there already is a
> really nice built in tool (JColorChooser) to do the job.

I'll look up the JColorChooser cuz I _have_ to be done by tomorrow with
the whole thing.

> Why don't you
> start writing it and post your progress and any question?

I'll see if I can really do the hex value computations. Maybe in a
couple of days I'll start working on it. As I said I'll go with the
JColorChooser for now since I want the program done by tomorrow.

Thanks again to everyone! I'll post a link to the final work so that you
can see it & try it if you want.

I'll be back.
Thomas A. Russ - 06 Feb 2004 21:12 GMT
> That's exactly what I want to do. I want to add a little JTextArea and
> print the color hex value in there. (The purpose is to make the app
> useful for web page designing - get the color value easily).

Well, if you really want to make it useful for web page designing, you
probably also will want to have the controls respect the so-called "Web
Safe" color constraints -- at least as an option.

That makes things a bit more difficult on the interface end, since you
would no longer be able to offer a complete continuum of input values.

Signature

Thomas A. Russ,  USC/Information Sciences Institute

Andrew Thompson - 07 Feb 2004 06:13 GMT
>> That's exactly what I want to do. I want to add a little JTextArea
>> and print the color hex value in there. (The purpose is to make the
[quoted text clipped - 3 lines]
> probably also will want to have the controls respect the so-called
> "Web Safe" color constraints -- at least as an option.

I would not worry about that, a discussion
on c.i.w.a.stylesheets recently had all the
gurus rejecting the need for web-safe colors
out of hand.

--
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology
Thomas Weidenfeller - 06 Feb 2004 08:09 GMT
> Thomas:

Yes?

> You will only need hex numbers if you want to display the color values
> in hex.

I? I don't need any hex numbers. I didn't ask that question.

> Why don't you
> start writing it and post your progress and any question?

Why? I didn't ask the question. Should I be in the need for a color
chooser I will use JColorChooser, as I have suggested to the original
poster.

/Thomas


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.