Java examples for 2D Graphics:Color
Converts a color into a String like "255,0,0,255" (red,green,blue,alpha).
/**//from w ww .j a v a 2 s . co m * Copyright 1998-2008, CHISEL Group, University of Victoria, Victoria, BC, Canada. * All rights reserved. */ //package com.java2s; import java.awt.Color; public class Main { /** * Converts a color into a String like "255,0,0,255" (red,green,blue,alpha). * @param color Color to convert into a String. * @return String color RGB String or the empty string */ public static String colorToRGBAString(Color color) { String rgba = ""; if (color != null) { rgba = color.getRed() + "," + color.getGreen() + "," + color.getBlue() + "," + color.getAlpha(); } return rgba; } }