From the documentation of Color#toString
Returns a string representation of this Color
. This method is intended to be used only for debugging purposes. The content and format of the returned string might vary between implementations. The returned string might be empty but cannot be null
.
In other words, I wouldn't rely on being able to back-convert the string to the Color
. If you insist on doing this, however, you can try to parse the numbers out of the string and hope that it will work with no guarantees.
Something like this seems to work for ME for NOW:
Scanner sc = new Scanner("java.awt.Color[r=1,g=2,b=3]");
sc.useDelimiter("\\D+");
Color color = new Color(sc.nextInt(), sc.nextInt(), sc.nextInt());
I don't recommend actually doing this, however.