Results 1 to 7 of 7
Thread: Convert String To Advanced Color
- 09-21-2011, 02:33 AM #1
Convert String To Advanced Color
Hello, I have a small problem with an application I am making. I am working on a program right now and in this program you can open up a JColorChooser to choose the color and it saves it out to a textfile. Then every time you launch the program it checks this textfile to try and set the color. My problem is I am not sure exactly how to convert it from a String to a color like this java.awt.Color[r=102,g=255,b=102]
One of the methods that I tried was this:
output = java.awt.Color[r=102,g=255,b=102]Java Code:Color back = Color.getColor(output);
- 09-21-2011, 02:41 AM #2
Re: Convert String To Advanced Color
You need to parse the String and extract the r,g and b values, convert them to ints so you can use them in the Coolor class's constructor.
- 09-21-2011, 02:46 AM #3
- 09-21-2011, 02:51 AM #4
Re: Convert String To Advanced Color
What format is the String that contains the values?
The String class has several methods for working your way through the contents of a String.
Look at the API doc for the String class.
-
Re: Convert String To Advanced Color
Why try to save the Color to a text file? If it needs to be saved, the Color class implements the Serializable interface, and so why not use serialization instead?
- 09-21-2011, 03:57 AM #6
-
Similar Threads
-
Hot to convert string to int ????
By java_no1 in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 06-07-2011, 07:40 AM -
String color
By biggerthanblue in forum Java 2DReplies: 1Last Post: 04-10-2011, 04:32 AM -
SetColor GOBJECT passing a string for color
By Hollywood_99 in forum New To JavaReplies: 0Last Post: 10-17-2010, 11:25 PM -
convert obj to string
By isme in forum New To JavaReplies: 11Last Post: 06-14-2010, 10:54 AM -
How to change string Color
By Java.child in forum AWT / SwingReplies: 3Last Post: 01-06-2009, 04:27 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks