Java uses RGB colors, where each component (red, green, blue) is in the range from 0 to 255. When all components have the same value, you get white-black-gray color. Combinations closer to 255 will be whiter and closer to 0 will be black. The function below will return a grayish color, while the amount of white will be reduced accordingly by input.
Color intToCol(int colNum) { int rgbNum = 255 - (int) ((colNum/50.0)*255.0); return new Color (rgbNum,rgbNum,rgbNum); }
source share