Save the color as a full 32-bit int (use Color.getRGB () ) and restore the color using Color (int, true)
This makes it difficult to edit the property files manually, as you will see numbers such as
somecolor = -123875123
Another fun example exit code
public static void main(String[] args) { Color r = Color.red; int ir = r.getRGB(); Color nr = new Color(ir, true); System.out.println(r + ":" + r.getAlpha() + ", " + ir + ", " + nr + ":" + nr.getAlpha()); Color c = new Color(1.0f, 0.5f, 1.0f, 0.5f); int ic = c.getRGB(); Color nc = new Color(ic, true); System.out.println(c + ":" + c.getAlpha() + ", " + ic + ", " + nc + ":" + nc.getAlpha()); }
Exit
java.awt.Color[r=255,g=0,b=0]:255, -65536, java.awt.Color[r=255,g=0,b=0]:255 java.awt.Color[r=255,g=128,b=255]:128, -2130738945, java.awt.Color[r=255,g=128,b=255]:128
source share