Java - 如何将Color.toString()转换为颜色? [英] Java - How to convert a Color.toString() into a Color?

查看:628
本文介绍了Java - 如何将Color.toString()转换为颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了在我的应用程序中保存图形对象的Color属性,我将这个Color的字符串表示保存在数据文件中。
例如,对于红色我保存: java.awt.Color [r = 255,g = 0,b = 0]
如何将这个字符串表示转换为一个颜色,以便我可以在加载我的数据文件后再次使用它?

In order to save Color attributes of a graphical object in my application, I saved the string representation of this Color in a data file. For instance, for red I save: java.awt.Color[r=255,g=0,b=0]. How can I convert this string representation into a Color so that I can use it again after loading my data file ?

谢谢。

推荐答案

使用 toString() 可能因实施方式而异。而是保存 String.valueOf(color.getRGB())以供以后重建。

这篇关于Java - 如何将Color.toString()转换为颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆