String to Object re-construction
I Have an Object. I have to transfer this Object thru Clipboard as an String only.
How can I reconstrcut the object from its String value.
eg. Color.red in String becomes java.awt.Color[r=255,g=0,b=0]
I want Color.red back from this above String.
I guess, I have to use Reflection. Any help pls?
Thanks
Use full words. 'pls' is a pain in the *** to read.My first thought would be to use a string parser to pull the R, G, Bvalues, and then use the Color(int, int, int) constructor.
You might be able to convert Color's toString() value back to a Color object, but you aren't going to be able to do that in general.Why do you have to use a String to transfer your data? At least on Windows the clipboard supports all kinds of data, not just text.
Yes the clipboard supports. But I use swing and don't know whether the Transferable supports Object[] or ArrayList of objects. By the way I got the Color.getRGB and passed that as String instead of the whole color object.
If you know how to transfer(DragnDrop) object array, pls le'me know.
Thanks